misc minor fixes and changes #1
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: GitHub Bot | |
on: | |
# Watch for changes on PR state, assignees, labels, head branch and draft/ready status | |
pull_request_target: | |
types: | |
- assigned | |
- unassigned | |
- labeled | |
- unlabeled | |
- opened | |
- reopened | |
- synchronize # PR head updated | |
- converted_to_draft | |
- ready_for_review | |
# Watch for changes on PR comment | |
issue_comment: | |
types: [created, edited, deleted] | |
# Manual run from GitHub Actions interface | |
workflow_dispatch: | |
inputs: | |
pull-request-list: | |
description: "PR(s) to process: specify 'all' or a comma separated list of PR numbers, e.g. '42,1337,7890'" | |
required: true | |
default: all | |
type: string | |
jobs: | |
# This job creates a matrix of PR numbers based on the inputs from the various | |
# events that can trigger this workflow so that the process-pr job below can | |
# handle the parallel processing of the pull-requests | |
define-prs-matrix: | |
name: Define PRs matrix | |
# Prevent bot from retriggering itself and ignore event emitted by codecov | |
if: ${{ github.actor != vars.GH_BOT_LOGIN && github.actor != 'codecov[bot]' }} | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: read | |
outputs: | |
pr-numbers: ${{ steps.pr-numbers.outputs.pr-numbers }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: contribs/github-bot/go.mod | |
- name: Generate matrix from event | |
id: pr-numbers | |
working-directory: contribs/github-bot | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: go run . matrix -matrix-key 'pr-numbers' -verbose | |
# This job processes each pull request in the matrix individually while ensuring | |
# that a same PR cannot be processed concurrently by mutliple runners | |
process-pr: | |
name: Process PR | |
needs: define-prs-matrix | |
# Just skip this job if PR numbers matrix is empty (prevent failed state) | |
if: ${{ needs.define-prs-matrix.outputs.pr-numbers != '[]' && needs.define-prs-matrix.outputs.pr-numbers != '' }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# Run one job for each PR to process | |
pr-number: ${{ fromJSON(needs.define-prs-matrix.outputs.pr-numbers) }} | |
concurrency: | |
# Prevent running concurrent jobs for a given PR number | |
group: ${{ matrix.pr-number }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: contribs/github-bot/go.mod | |
- name: Run GitHub Bot | |
working-directory: contribs/github-bot | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_BOT_PAT }} | |
run: go run . check -pr-numbers '${{ matrix.pr-number }}' -verbose |