action

2023-10-12

可用于自动执行生成、测试和部署管道。

需要在仓库 .github/workflows/ 目录下创建 .yml 文件,下面是一个自动更新私有仓库子模块的示例:

name: update-submodule
on:
schedule:
- cron: '0 1 * * *'
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.DOCS_TOKEN }}
submodules: 'true'
- name: pull sumbodule
run: |
git submodule update --init --remote
- name: push update
run: |
git config --global user.name 'immbot'
git config --global user.email '[email protected]'
git commit -am "auto updated submodule" || exit 0
git push
  • cron:参数是标准的 cron 格式,时区是 UTC(没办法更改)
  • token:即使是自己的私有仓库,仍然需要配置 Token 才能访问
  • exit 0:避免在子仓库无更新的情况下出现报错

参考