简体   繁体   English

Github 尽管计划应触发作业,但未触发操作工作流

[英]Github Actions workflow not triggered although schedule should trigger the job

I'm trying to auto-assign issues and PRs in Github from a Github Actions workflow.我正在尝试从 Github 操作工作流自动分配 Github 中的问题和 PR。 The respective steps work fine when an issue / a PR is opened.打开问题/PR 时,各个步骤都可以正常工作。 So this trigger is fine.所以这个触发器很好。

Recently I added Dependabot to my repo.最近我将 Dependabot 添加到我的仓库中。 Since Dependabot cannot access my secrets I cannot assign any issue in a Dependabot-triggeres pipeline.由于 Dependabot 无法访问我的机密,因此我无法在 Dependabot-triggeres 管道中分配任何问题。 So I just thought I run this pipeline with a scheduler one per day to "clean up" every issue and PR which is unassigned.所以我只是想我每天用一个调度程序运行这个管道来“清理”每个未分配的问题和 PR。 But this schedule config does not trigger the pipeline.但是此计划配置不会触发管道。 It simply does nothing, not even show as a pipeline run which does nothing (with all jobs skipped).它什么都不做,甚至不显示为什么都不做的管道运行(跳过所有作业)。 Seems like the trigger is completely ignored.似乎触发器被完全忽略了。

This is my workflow file.这是我的工作流程文件。

---
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

What bugs me is that the scheduler setting is copied from another workflow where it works just fine.让我感到困扰的是,调度程序设置是从另一个工作正常的工作流程中复制的。 So I cannot think of a reason why this pipeline is not triggered at 09:00 in the morning.所以我想不出为什么这个管道没有在早上 09:00 触发的原因。

Found a way:-)找到了一个方法:-)

I use the Github CLI to get all PRs with a certain label and assign a user.我使用 Github CLI 获取具有特定 label 的所有 PR 并分配一个用户。 This is a new dedicated pipeline.这是一个新的专用管道。

---
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

Then I updated the triggers of my original pipeline to然后我将原始管道的触发器更新为

on:
  issues:
    types:
      - opened
  pull_request:
    types:
      - opened
      - assigned

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 github 操作从 Github 中的存储库 A 的工作流作业触发存储库 B(下游作业)中的工作流作业 - How to trigger a workflow job in repository B(downstream job) from workflow job of repository A in Github using github actions 在 Github 操作工作流中获取当前作业名称 - Get current job name in Github Actions workflow 在 GitHub Actions 中停止已经运行的工作流/作业 - Stop already running workflow/job in GitHub Actions 如何在工作流失败时运行 github 操作作业? - How to run a github actions job on workflow failure? Github 操作:将评论发布到触发当前工作流的 PR 工作流 - Github actions: Post comment to PR workflow that triggered the current workflow Github 操作 - 取消/手动触发工作流程 - Github actions - cancel/manually trigger workflow GitHub 发布操作创建的工作流触发器不起作用 - GitHub Actions on release created workflow trigger not working 在另一个工作流成功运行后手动触发 Github Actions 工作流 - Manually trigger Github Actions workflow after another workflow successfully runs 在更改代码的目录中执行 github 操作工作流/作业 - Execute github actions workflow/job in directory where code was changed 获取整个 Github 操作工作流程的 state,而不仅仅是单个作业 - Get the state of the whole Github Actions workflow, not just a single job
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM