可用于自动执行生成、测试和部署管道。
需要在仓库 .github/workflows/ 目录下创建 .yml 文件,下面是一个自动更新私有仓库子模块的示例:
1name: update-submodule2
3on:4 schedule:5 - cron: '0 1 * * *'6 workflow_dispatch:7
8jobs:9 sync:10 runs-on: ubuntu-latest11 steps:12 - name: checkout13 uses: actions/checkout@v414 with:15 token: ${{ secrets.DOCS_TOKEN }}16 submodules: 'true'17
18 - name: pull sumbodule19 run: |20 git submodule update --init --remote21
22 - name: push update23 run: |24 git config --global user.name 'immbot'25 git config --global user.email '[email protected]'26 git commit -am "auto updated submodule" || exit 027 git push
- cron:参数是标准的 cron 格式,时区是 UTC(没办法更改)
- token:即使是自己的私有仓库,仍然需要配置 Token 才能访问
- exit 0:避免在子仓库无更新的情况下出现报错