|
| 1 | +name: "On Issue Comment" |
| 2 | + |
| 3 | +on: |
| 4 | + issue_comment: |
| 5 | + types: [created] |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: write |
| 9 | + issues: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + # This job always runs to prevent GHA from marking the run as failed when |
| 14 | + # all other jobs are skipped. |
| 15 | + noop: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - run: echo "No-op" |
| 19 | + |
| 20 | + parse_comment: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + if: | |
| 23 | + github.event.issue.pull_request == null && |
| 24 | + contains(github.event.issue.labels.*.name, 'type: release') && |
| 25 | + (github.event.comment.author_association == 'OWNER' || |
| 26 | + github.event.comment.author_association == 'MEMBER' || |
| 27 | + github.event.comment.author_association == 'COLLABORATOR') |
| 28 | + outputs: |
| 29 | + command: ${{ steps.parse.outputs.command }} |
| 30 | + issue_number: ${{ github.event.issue.number }} |
| 31 | + backports: ${{ steps.parse.outputs.backports }} |
| 32 | + steps: |
| 33 | + - name: Parse comment |
| 34 | + id: parse |
| 35 | + env: |
| 36 | + COMMENT_BODY: ${{ github.event.comment.body }} |
| 37 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 38 | + run: | |
| 39 | + if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/create-rc([[:space:]]|$)'; then |
| 40 | + echo "command=create-rc" >> "$GITHUB_OUTPUT" |
| 41 | + elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/prepare([[:space:]]|$)'; then |
| 42 | + echo "command=prepare" >> "$GITHUB_OUTPUT" |
| 43 | + elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/process-backports([[:space:]]|$)'; then |
| 44 | + echo "command=process-backports" >> "$GITHUB_OUTPUT" |
| 45 | + elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/add-backports([[:space:]]|$)'; then |
| 46 | + args=$(echo "$COMMENT_BODY" | grep -E '^[[:space:]]*/add-backports([[:space:]]|$)' | sed -E 's/^[[:space:]]*\/add-backports[[:space:]]*//') |
| 47 | + # Strip leading/trailing spaces and commas |
| 48 | + args=$(echo "$args" | sed -e 's/^[[:space:],]*//' -e 's/[[:space:],]*$//') |
| 49 | + # Replace internal spaces/commas with single comma |
| 50 | + csv=$(echo "$args" | sed -E 's/[[:space:],]+/ /g' | tr ' ' ',') |
| 51 | + if [ -n "$csv" ]; then |
| 52 | + echo "command=add-backports" >> "$GITHUB_OUTPUT" |
| 53 | + echo "backports=$csv" >> "$GITHUB_OUTPUT" |
| 54 | + else |
| 55 | + echo "command=none" >> "$GITHUB_OUTPUT" |
| 56 | + echo "Error: No PRs specified for add-backports." >&2 |
| 57 | + gh api \ |
| 58 | + --method POST \ |
| 59 | + -H "Accept: application/vnd.github+json" \ |
| 60 | + -H "X-GitHub-Api-Version: 2022-11-28" \ |
| 61 | + /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \ |
| 62 | + -f "content=-1" |
| 63 | + fi |
| 64 | + elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/promote([[:space:]]|$)'; then |
| 65 | + echo "command=promote" >> "$GITHUB_OUTPUT" |
| 66 | + else |
| 67 | + echo "command=none" >> "$GITHUB_OUTPUT" |
| 68 | + fi |
| 69 | +
|
| 70 | + call_create_rc: |
| 71 | + needs: parse_comment |
| 72 | + if: needs.parse_comment.outputs.command == 'create-rc' |
| 73 | + uses: ./.github/workflows/release_create_rc.yaml |
| 74 | + with: |
| 75 | + issue: ${{ needs.parse_comment.outputs.issue_number }} |
| 76 | + comment_id: "${{ github.event.comment.id }}" |
| 77 | + secrets: inherit |
| 78 | + |
| 79 | + call_prepare: |
| 80 | + needs: parse_comment |
| 81 | + if: needs.parse_comment.outputs.command == 'prepare' |
| 82 | + uses: ./.github/workflows/release_prepare.yaml |
| 83 | + with: |
| 84 | + issue: ${{ needs.parse_comment.outputs.issue_number }} |
| 85 | + secrets: inherit |
| 86 | + |
| 87 | + call_process_backports: |
| 88 | + needs: parse_comment |
| 89 | + if: | |
| 90 | + needs.parse_comment.outputs.command == 'process-backports' || |
| 91 | + needs.parse_comment.outputs.command == 'add-backports' |
| 92 | + uses: ./.github/workflows/release_process_backports.yaml |
| 93 | + with: |
| 94 | + issue: ${{ needs.parse_comment.outputs.issue_number }} |
| 95 | + add_backports: ${{ needs.parse_comment.outputs.command == 'add-backports' && needs.parse_comment.outputs.backports || '' }} |
| 96 | + comment_id: "${{ github.event.comment.id }}" |
| 97 | + secrets: inherit |
| 98 | + |
| 99 | + call_promote: |
| 100 | + needs: parse_comment |
| 101 | + if: needs.parse_comment.outputs.command == 'promote' |
| 102 | + uses: ./.github/workflows/release_promote_rc.yaml |
| 103 | + with: |
| 104 | + issue: ${{ needs.parse_comment.outputs.issue_number }} |
| 105 | + secrets: inherit |
0 commit comments