IT评测·应用市场-qidao123.com技术社区

标题: dify工作流+github actions实现翻译并创建PR [打印本页]

作者: 诗林    时间: 2024-12-22 10:25
标题: dify工作流+github actions实现翻译并创建PR
受bookmark-summary开导,制作了一套翻译流程,利用浏览器插件收藏文章后,自动翻译并提交pr到github仓库,流程如下:

流程

浏览器插件Memo

浏览器收藏页面,支持添加标签,可以根据标签执行不同的流程,需要翻译的文章我会在增加一个#translate标签

github actions

github actions会监听到浏览器插件的收藏事件(仓库中markdown文件会新增一行),然后调用dify workflow翻译文章,翻译效果会提交到github仓库
dify workflow

利用jina抓取网页内容,返回markdown格式,在调用gpt翻译
创建pr

利用github actions创建pr
设置:
  1. # 创建pr
  2. - name: pr blog
  3.   uses: peter-evans/create-pull-request@v7
  4.   with:
  5.     path: blog # 需要pr的repo位置
  6.     token: ${{ secrets.GH_TOKEN }} # github accesstoken
  7.     commit-message: 提交翻译到仓库
  8.     committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  9.     author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
  10.     signoff: false
  11.     branch: posts
  12.     delete-branch: true
  13.     title: "提交翻译到仓库"
  14.     body: |
  15.       新增翻译内容
  16.       - Auto-generated by [create-pull-request][1]
  17.       [1]: https://github.com/peter-evans/create-pull-request
  18.     labels: |
  19.       automated pr : translate
  20.     draft: false
复制代码
注意

在一个github action 任务中checkout出2个仓库时有些需要注意的点,防止踩坑:

  1. - name: Checkout bookmark
  2.   uses: actions/checkout@v4
  3.   with:
  4.     path: bookmark
  5. # 需要再blog repo打开配置 Access-> Accessible from repositories owned by the user 'yiGmMk'
  6. - name: Checkout blog
  7.   uses: actions/checkout@v4
  8.   with:
  9.     token: ${{ secrets.GH_TOKEN }}
  10.     path: blog
  11.     repository: yiGmMk/blog
  12.     ref: master
复制代码
效果

效果
工具

在这个流程中利用的工具:


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 IT评测·应用市场-qidao123.com技术社区 (https://dis.qidao123.com/) Powered by Discuz! X3.4