我目前正在测试 GitHub Actions 工作流程这个存储库 https://github.com/GuillaumeFalourd/poc-github-actions。我正在尝试使用这个工作流程 https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/workflows/19-checkout-action.yml:
on:
workflow_dispatch:
jobs:
job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
date > report.txt
git config user.name github-actions
git config user.email [email protected] /cdn-cgi/l/email-protection
git add .
git commit -m "generate or update report.txt file"
git push
引起这个工作流程 https://github.com/GuillaumeFalourd/poc-github-actions/blob/main/.github/workflows/18-specific-file.yml:
on:
push:
paths:
- '**/report.txt'
pull_request:
paths:
- '**/report.txt'
jobs:
job:
runs-on: ubuntu-latest
steps:
- run: echo "Report .txt file has been updated"
我跟着GitHub 操作文档 https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#onpushpull_requestpaths实施第二个工作流程过滤模式 https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet.
当我更新report.txt
本地文件,然后提交并将代码推送到存储库,第二个工作流程触发。
但是,我不明白为什么当第一个工作流程完成时第二个工作流程不会触发,即使使用report.txt
文件正在默认分支上更新。我是否错过了第一个工作流程中的某些内容以使其触发第二个工作流程,或者我应该在第二个工作流程中添加某些内容以使其由第一个工作流程触发?
我知道我可以使用其他触发事件类型触发第二个工作流程(示例:repository_dispatch
or workflow_run
),但我试图从git push
另一个工作流程上的命令。