From 3467e0c9069aa9258b94de472cd51ce51643edcc Mon Sep 17 00:00:00 2001 From: David Zager Date: Mon, 5 Feb 2024 10:19:08 -0500 Subject: [PATCH] :sparkles: reconcile issue reusable workflow (#58) Introduce a reusable workflow that can be used by Konveyor projects to: 1. look for `triage/accepted` label. Adds `needs-triage` if missing. 1. look for `kind/` label. Add `needs-kind` if missing. 1. look for `priority/` label. Add `needs-priority` if missing. When the event type is created/opened, then add it to the Planning board. This PR also introduces a reusable workflow to handle issue comments. In much the same way the kube prow `label` plugin can handle `/kind bug` or `/triage accepted` commands (and their negatives `/remove-kind bug` or `/remove-triage accepted`), this workflow attempts to handle those commands that could be put in issue comments to make triaging a little more straightforward. Fixes #57 Signed-off-by: David Zager --- .github/workflows/_issue_comment.yaml | 12 ++ .github/workflows/_issues.yaml | 25 +++ .../workflows/reconcile-issue-comment.yaml | 116 +++++++++++++ .github/workflows/reconcile-issue.yaml | 156 ++++++++++++++++++ pkg/config/config.yaml | 6 + 5 files changed, 315 insertions(+) create mode 100644 .github/workflows/_issue_comment.yaml create mode 100644 .github/workflows/_issues.yaml create mode 100644 .github/workflows/reconcile-issue-comment.yaml create mode 100644 .github/workflows/reconcile-issue.yaml diff --git a/.github/workflows/_issue_comment.yaml b/.github/workflows/_issue_comment.yaml new file mode 100644 index 0000000..bec9f25 --- /dev/null +++ b/.github/workflows/_issue_comment.yaml @@ -0,0 +1,12 @@ +name: Handle Issue Comment + +on: + issue_comment: + +jobs: + reconcile-issue-comment: + permissions: + contents: write + issues: write + pull-requests: write + uses: ./.github/workflows/reconcile-issue-comment.yaml diff --git a/.github/workflows/_issues.yaml b/.github/workflows/_issues.yaml new file mode 100644 index 0000000..f1437cd --- /dev/null +++ b/.github/workflows/_issues.yaml @@ -0,0 +1,25 @@ +name: Reconcile GitHub Issue + +on: + issues: + types: + - opened + - edited + - closed + - reopened + - labeled + - unlabeled + +# This prevents potential race conditions by only allowing this action to handle +# one update at a time for a given issue. +concurrency: + group: reconcile-issue-${{ github.event.issue.number }} + cancel-in-progress: true + +jobs: + reconcile-issue: + permissions: + contents: write + issues: write + pull-requests: write + uses: ./.github/workflows/reconcile-issue.yaml diff --git a/.github/workflows/reconcile-issue-comment.yaml b/.github/workflows/reconcile-issue-comment.yaml new file mode 100644 index 0000000..b6252fc --- /dev/null +++ b/.github/workflows/reconcile-issue-comment.yaml @@ -0,0 +1,116 @@ +name: Reusable Reconcile Issue Comment + +on: + workflow_call: + +jobs: + event_type: + name: Check event type + runs-on: ubuntu-latest + if: > + github.event_name == 'issue_comment' && + ( + github.event.action == 'created' || + github.event.action == 'edited' + ) + steps: + - name: ok + run: /bin/true + + addLabels: + needs: event_type + name: Add Labels + runs-on: ubuntu-latest + steps: + - name: ok + uses: actions/github-script@v7 + with: + script: | + const commentRegex = /()|()|(