feat(cc): introduce py_extension rule for C/C++ Python extension modules #130
This file contains hidden or 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: "On Comment" | |
| on: | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| # This job always runs to prevent GHA from marking the run as failed when | |
| # all other jobs are skipped. | |
| noop: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: echo "No-op" | |
| parse_comment: | |
| runs-on: ubuntu-latest | |
| if: | | |
| github.event.comment.author_association == 'OWNER' || | |
| github.event.comment.author_association == 'MEMBER' || | |
| github.event.comment.author_association == 'COLLABORATOR' | |
| outputs: | |
| command: ${{ steps.parse.outputs.command }} | |
| issue_number: ${{ steps.parse.outputs.issue_number }} | |
| pr_number: ${{ steps.parse.outputs.pr_number }} | |
| backports: ${{ steps.parse.outputs.backports }} | |
| steps: | |
| - name: Parse comment | |
| id: parse | |
| env: | |
| COMMENT_BODY: ${{ github.event.comment.body }} | |
| IS_PR: "${{ github.event.issue.pull_request != null }}" | |
| EVENT_NUMBER: "${{ github.event.issue.number }}" | |
| HAS_RELEASE_LABEL: "${{ contains(github.event.issue.labels.*.name, 'type: release') }}" | |
| HAS_BACKPORT_LABEL: "${{ contains(github.event.issue.labels.*.name, 'type: backport-pr') }}" | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| if [ "$IS_PR" = "false" ]; then | |
| # Set issue number for non-PR issues (release or backport tracking issues) | |
| issue_number=$EVENT_NUMBER | |
| echo "issue_number=$issue_number" >> "$GITHUB_OUTPUT" | |
| echo "issue_number=$issue_number" >> "$GITHUB_ENV" | |
| # Check if it's a release tracking issue | |
| if [ "$HAS_RELEASE_LABEL" = "true" ]; then | |
| # Handle /create-rc comment | |
| if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/create-rc([[:space:]]|$)'; then | |
| echo "command=create-rc" >> "$GITHUB_OUTPUT" | |
| # Handle /prepare comment | |
| elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/prepare([[:space:]]|$)'; then | |
| echo "command=prepare" >> "$GITHUB_OUTPUT" | |
| # Handle /process-backports comment | |
| elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/process-backports([[:space:]]|$)'; then | |
| echo "command=process-backports" >> "$GITHUB_OUTPUT" | |
| # Handle /add-backports comment | |
| elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/add-backports([[:space:]]|$)'; then | |
| args=$(echo "$COMMENT_BODY" | grep -E '^[[:space:]]*/add-backports([[:space:]]|$)' | sed -E 's/^[[:space:]]*\/add-backports[[:space:]]*//') | |
| args=$(echo "$args" | sed -e 's/^[[:space:],]*//' -e 's/[[:space:],]*$//') | |
| csv=$(echo "$args" | sed -E 's/[[:space:],]+/ /g' | tr ' ' ',') | |
| if [ -n "$csv" ]; then | |
| echo "command=add-backports" >> "$GITHUB_OUTPUT" | |
| echo "backports=$csv" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "command=none" >> "$GITHUB_OUTPUT" | |
| echo "Error: No PRs specified for add-backports." >&2 | |
| gh api \ | |
| --method POST \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "X-GitHub-Api-Version: 2022-11-28" \ | |
| /repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \ | |
| -f "content=-1" | |
| fi | |
| # Handle /promote comment | |
| elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/promote([[:space:]]|$)'; then | |
| echo "command=promote" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "command=none" >> "$GITHUB_OUTPUT" | |
| fi | |
| # Check if it's a backport tracking issue | |
| elif [ "$HAS_BACKPORT_LABEL" = "true" ]; then | |
| # Handle /prepare comment for backports | |
| if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/prepare([[:space:]]|$)'; then | |
| echo "command=backport-prepare" >> "$GITHUB_OUTPUT" | |
| # Handle /create-releases comment for backports | |
| elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/create-releases([[:space:]]|$)'; then | |
| echo "command=backport-create-releases" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "command=none" >> "$GITHUB_OUTPUT" | |
| fi | |
| else | |
| echo "command=none" >> "$GITHUB_OUTPUT" | |
| fi | |
| elif [ "$IS_PR" = "true" ]; then | |
| pr_number=$EVENT_NUMBER | |
| # Handle /backport comment on PR | |
| if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/backport([[:space:]]|$)'; then | |
| echo "command=pr-backport" >> "$GITHUB_OUTPUT" | |
| echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "command=none" >> "$GITHUB_OUTPUT" | |
| fi | |
| else | |
| echo "command=none" >> "$GITHUB_OUTPUT" | |
| fi | |
| call_create_rc: | |
| needs: parse_comment | |
| if: needs.parse_comment.outputs.command == 'create-rc' | |
| uses: ./.github/workflows/release_create_rc.yaml | |
| with: | |
| issue: ${{ needs.parse_comment.outputs.issue_number }} | |
| comment_id: "${{ github.event.comment.id }}" | |
| secrets: inherit | |
| call_prepare: | |
| needs: parse_comment | |
| if: needs.parse_comment.outputs.command == 'prepare' | |
| uses: ./.github/workflows/release_prepare.yaml | |
| with: | |
| issue: ${{ needs.parse_comment.outputs.issue_number }} | |
| secrets: inherit | |
| call_add_backports: | |
| needs: parse_comment | |
| if: | | |
| needs.parse_comment.outputs.command == 'add-backports' || | |
| needs.parse_comment.outputs.command == 'pr-backport' | |
| uses: ./.github/workflows/release_add_backports.yaml | |
| with: | |
| prs: ${{ needs.parse_comment.outputs.command == 'pr-backport' && needs.parse_comment.outputs.pr_number || needs.parse_comment.outputs.backports }} | |
| issue: ${{ needs.parse_comment.outputs.issue_number }} | |
| secrets: inherit | |
| call_process_backports_after_add: | |
| needs: [parse_comment, call_add_backports] | |
| if: needs.parse_comment.outputs.command == 'add-backports' | |
| uses: ./.github/workflows/release_process_backports.yaml | |
| with: | |
| issue: ${{ needs.parse_comment.outputs.issue_number }} | |
| comment_id: "${{ github.event.comment.id }}" | |
| secrets: inherit | |
| call_process_backports_only: | |
| needs: parse_comment | |
| if: needs.parse_comment.outputs.command == 'process-backports' | |
| uses: ./.github/workflows/release_process_backports.yaml | |
| with: | |
| issue: ${{ needs.parse_comment.outputs.issue_number }} | |
| comment_id: "${{ github.event.comment.id }}" | |
| secrets: inherit | |
| call_promote: | |
| needs: parse_comment | |
| if: needs.parse_comment.outputs.command == 'promote' | |
| uses: ./.github/workflows/release_promote.yaml | |
| with: | |
| issue: ${{ needs.parse_comment.outputs.issue_number }} | |
| secrets: inherit | |
| call_backport_prepare: | |
| needs: parse_comment | |
| if: needs.parse_comment.outputs.command == 'backport-prepare' | |
| uses: ./.github/workflows/backport_prepare.yaml | |
| with: | |
| issue: ${{ needs.parse_comment.outputs.issue_number }} | |
| secrets: inherit | |
| call_backport_create_releases: | |
| needs: parse_comment | |
| if: needs.parse_comment.outputs.command == 'backport-create-releases' | |
| uses: ./.github/workflows/backport_create_releases.yaml | |
| with: | |
| issue: ${{ needs.parse_comment.outputs.issue_number }} | |
| secrets: inherit |