![](/img/trans.png)
[英]How to trigger a workflow job in repository B(downstream job) from workflow job of repository A in Github using github actions
[英]Github Actions workflow not triggered although schedule should trigger the job
我正在尝试从 Github 操作工作流自动分配 Github 中的问题和 PR。 打开问题/PR 时,各个步骤都可以正常工作。 所以这个触发器很好。
最近我将 Dependabot 添加到我的仓库中。 由于 Dependabot 无法访问我的机密,因此我无法在 Dependabot-triggeres 管道中分配任何问题。 所以我只是想我每天用一个调度程序运行这个管道来“清理”每个未分配的问题和 PR。 但是此计划配置不会触发管道。 它什么都不做,甚至不显示为什么都不做的管道运行(跳过所有作业)。 似乎触发器被完全忽略了。
这是我的工作流程文件。
---
name: "Organize: Assign Issues + Pull Requests"
on:
issues:
types:
- opened
pull_request:
types:
- opened
schedule:
- cron: '0 9 * * *' # https://crontab.guru/#0_11_*_*_*
permissions:
contents: read
issues: write
pull-requests: write
jobs:
add-to-project:
name: Add to project
runs-on: ubuntu-latest
steps:
- name: Add to project (issues and PRs)
uses: actions/add-to-project@main
with:
project-url: https://github.com/users/sebastian-sommerfeld-io/projects/1
github-token: ${{ secrets.GH_TOKEN_REPO_AND_PROJECT }}
assign-to-user:
name: Assign to user
runs-on: ubuntu-latest
steps:
- name: Assign issue to user when moved into column
uses: pozil/auto-assign-issue@v1
# https://github.com/marketplace/actions/auto-assign-issue
with:
assignees: ${{ github.actor }}
numOfAssignee: 1
allowSelfAssign: true
abortIfPreviousAssignees: true
new-pull-request-chat-message:
runs-on: ubuntu-latest
needs: ['add-to-project', 'assign-to-user']
if: github.event_name == 'pull_request'
steps:
- name: Send message to Google Chat
uses: Co-qn/google-chat-notification@releases/v1
with:
name: New Pull Request "${{ github.event.pull_request.title }}" (raised by ${{ github.actor }})
url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
status: ${{ job.status }}
on-failure:
runs-on: ubuntu-latest
needs: ['add-to-project', 'assign-to-user', 'new-pull-request-chat-message']
if: failure()
steps:
- name: Send Pipeline Status to Google Chat
if: always()
uses: Co-qn/google-chat-notification@releases/v1
with:
name: ${{ github.workflow }}
url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }}
status: failure
让我感到困扰的是,调度程序设置是从另一个工作正常的工作流程中复制的。 所以我想不出为什么这个管道没有在早上 09:00 触发的原因。
找到了一个方法:-)
我使用 Github CLI 获取具有特定 label 的所有 PR 并分配一个用户。 这是一个新的专用管道。
---
name: "Organize: Dependabot Pull Requests"
on:
schedule:
- cron: '30 * * * *' # https://crontab.guru
permissions:
contents: read
issues: write
pull-requests: write
jobs:
assign-user:
name: Aassign PRs with label 'dependencies'
runs-on: ubuntu-latest
steps:
- name: Get PR and assign user (filtered by github cli)
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO_AND_PROJECT }}
label: dependencies
assignee: sebastian-sommerfeld-io
run: |
OUTPUT=""
pr_ids="$(gh pr list --repo "$GITHUB_REPOSITORY" --label "$label" --json number --jq '.[].number')"
for id in $pr_ids; do
gh pr edit "$id" --repo "$GITHUB_REPOSITORY" --add-assignee "$assignee"
done
然后我将原始管道的触发器更新为
on:
issues:
types:
- opened
pull_request:
types:
- opened
- assigned
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.