![](/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.