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

配置:

yaml 复制代码
# 创建pr
- name: pr blog
  uses: peter-evans/create-pull-request@v7
  with:
    path: blog # 需要pr的repo位置
    token: ${{ secrets.GH_TOKEN }} # github accesstoken
    commit-message: 提交翻译到仓库
    committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
    author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
    signoff: false
    branch: posts
    delete-branch: true
    title: "提交翻译到仓库"
    body: |
      新增翻译内容
      - Auto-generated by [create-pull-request][1]
      [1]: https://github.com/peter-evans/create-pull-request
    labels: |
      automated pr : translate
    draft: false
注意

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

  • pr的目标仓库需要先设置允许访问(设置中打开 "Accessible from repositories owned by the user xxx"),否则会报错
yaml 复制代码
- name: Checkout bookmark
  uses: actions/checkout@v4
  with:
    path: bookmark

# 需要再blog repo打开配置 Access-> Accessible from repositories owned by the user 'yiGmMk'
- name: Checkout blog
  uses: actions/checkout@v4
  with:
    token: ${{ secrets.GH_TOKEN }}
    path: blog
    repository: yiGmMk/blog
    ref: master

效果

效果

工具

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

相关推荐
摇滚侠40 分钟前
零基础小白自学 Git_Github 教程,git 命令行操作1,笔记18
笔记·git·github
无限进步_1 小时前
C++从入门到类和对象完全指南
开发语言·c++·windows·git·后端·github·visual studio
itwangyang5201 小时前
在 GitHub 上生成和配置个人访问令牌(PAT),并将其用于 R 环境中的凭证管理和包安装。
开发语言·r语言·github
love530love2 小时前
【ComfyUI/SD环境管理指南(二)】:如何避免插件安装导致的环境崩溃与“外科手术式”修复
人工智能·windows·python·stable diffusion·github·aigc·comfyui
Jonathan Star3 小时前
Git 的 pre-commit hook(以及其他钩子脚本)默认不会被 git commit 追踪,也不会被 git push 推送到远程仓库
github
无限进步_3 小时前
C++初始化列表详解:语法、规则与最佳实践
java·开发语言·数据库·c++·git·github·visual studio
无限进步_3 小时前
C++运算符重载完全指南:从基础到实战应用
开发语言·数据库·c++·windows·git·github·visual studio
逛逛GitHub4 小时前
盘点 近期优秀的 GitHub 开源项目。
github
致Great4 小时前
DeepSeek-V3.2技术报告解读:开源大模型的逆袭之战——如何用10%算力追平GPT-5
人工智能·gpt·开源·大模型·agent·智能体
nil4 小时前
shortcutkey:跨平台快捷键管理工具的设计与实现
python·开源·github