118 lines
4.1 KiB
YAML
118 lines
4.1 KiB
YAML
name: "Comment Commands"
|
|
|
|
on:
|
|
issue_comment:
|
|
types:
|
|
- created
|
|
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
ISSUE_NUMBER: ${{ github.event.issue.number }}
|
|
|
|
jobs:
|
|
issue-comment-job:
|
|
if: ${{ !github.event.issue.pull_request }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set-up Comvent
|
|
uses: rytswd/comvent@2168693e29bb394d0a8fd5788ffcccd16cadcffc # main
|
|
id: comvent
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
config-path: .github/comment-commands.yml
|
|
|
|
- if: steps.comvent.outputs.confirm-bug != ''
|
|
name: Handle confirmation command - Label
|
|
run: |
|
|
gh issue edit "$ISSUE_NUMBER" --remove-label "(S1 - Need Confirmation),stale"
|
|
gh issue edit "$ISSUE_NUMBER" --add-label "(S2 - Confirmed)"
|
|
gh issue reopen "$ISSUE_NUMBER"
|
|
|
|
- if: steps.comvent.outputs.close-duplicate != ''
|
|
name: Handle duplicate issue command - Label
|
|
run: |
|
|
gh issue edit "$ISSUE_NUMBER" --remove-label "(S1 - Need Confirmation),(S2 - Confirmed),stale"
|
|
gh issue edit "$ISSUE_NUMBER" --add-label "(S3 - Duplicate)"
|
|
|
|
- if: steps.comvent.outputs.close-invalid != ''
|
|
name: Handle invalid issue command - Label
|
|
run: |
|
|
gh issue edit "$ISSUE_NUMBER" --remove-label "(S1 - Need Confirmation),(S2 - Confirmed),stale"
|
|
gh issue edit "$ISSUE_NUMBER" --add-label "(S4 - Invalid)"
|
|
|
|
- if: steps.comvent.outputs.good-first-issue != ''
|
|
name: Handle good first issue command - Label
|
|
run: |
|
|
gh issue edit "$ISSUE_NUMBER" --remove-label "stale"
|
|
gh issue edit "$ISSUE_NUMBER" --add-label "Good First Issue"
|
|
gh issue reopen "$ISSUE_NUMBER"
|
|
|
|
- if: steps.comvent.outputs.help-wanted != ''
|
|
name: Handle help wanted command - Label
|
|
run: |
|
|
gh issue edit "$ISSUE_NUMBER" --remove-label "stale"
|
|
gh issue edit "$ISSUE_NUMBER" --add-label "Help Wanted"
|
|
gh issue reopen "$ISSUE_NUMBER"
|
|
|
|
pr-comment-job:
|
|
if: ${{ github.event.issue.pull_request }}
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
issues: write
|
|
pull-requests: write
|
|
actions: write
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Set-up Comvent
|
|
uses: rytswd/comvent@2168693e29bb394d0a8fd5788ffcccd16cadcffc # main
|
|
id: comvent
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
config-path: .github/comment-commands.yml
|
|
|
|
- if: steps.comvent.outputs.help-wanted != ''
|
|
name: Handle help wanted command - Label
|
|
run: |
|
|
gh pr edit "$ISSUE_NUMBER" --remove-label "stale"
|
|
gh pr edit "$ISSUE_NUMBER" --add-label "Help Wanted"
|
|
gh pr reopen "$ISSUE_NUMBER"
|
|
|
|
- if: steps.comvent.outputs.retry-jobs != ''
|
|
name: Re-run failed CI jobs
|
|
run: |
|
|
HEAD_SHA=$(gh pr view "$ISSUE_NUMBER" --json headRefOid -q .headRefOid)
|
|
FAILED_RUNS=$(gh run list --commit "$HEAD_SHA" --status failure --json databaseId -q '.[].databaseId')
|
|
if [ -z "$FAILED_RUNS" ]; then
|
|
echo "No failed runs found for PR #$ISSUE_NUMBER"
|
|
exit 0
|
|
fi
|
|
|
|
# Collect failed job details
|
|
COMMENT="Retried failed jobs:"
|
|
while read -r run_id; do
|
|
JOBS=$(gh run view "$run_id" --json jobs \
|
|
-q '.jobs[] | select(.conclusion == "failure") | "- [\(.name)](\(.url))"')
|
|
if [ -n "$JOBS" ]; then
|
|
COMMENT="$COMMENT
|
|
$JOBS"
|
|
fi
|
|
done <<< "$FAILED_RUNS"
|
|
|
|
# Re-run failed jobs
|
|
while read -r run_id; do
|
|
echo "Re-running failed jobs in run $run_id"
|
|
gh run rerun "$run_id" --failed
|
|
done <<< "$FAILED_RUNS"
|
|
|
|
gh pr comment "$ISSUE_NUMBER" --body "$COMMENT"
|