|
39 | 39 | private-key: ${{ secrets.GITGITGADGET_GIT_GITHUB_APP_PRIVATE_KEY }}
|
40 | 40 | owner: dscho
|
41 | 41 | repositories: git
|
| 42 | + - name: create a check run |
| 43 | + id: create-check-run |
| 44 | + run: | |
| 45 | + title="Handle PR comment" |
| 46 | + summary="Handling PR comment $PR_COMMENT_URL" |
| 47 | + details_url="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
| 48 | + text="This handles $PR_COMMENT_URL, see $details_url for details." |
| 49 | + echo "title=$title" >> $GITHUB_OUTPUT |
| 50 | + echo "summary=$summary" >> $GITHUB_OUTPUT |
| 51 | + echo "text=$text" >> $GITHUB_OUTPUT |
| 52 | +
|
| 53 | + PR_NUMBER="${PR_COMMENT_URL%#*}" # skip the suffix with the comment ID |
| 54 | + PR_NUMBER="${PR_NUMBER##*/}" # skip the prefix before the PR number |
| 55 | +
|
| 56 | + export GH_TOKEN="${{ secrets.GITHUB_TOKEN }}" |
| 57 | + eval "$(gh api repos/gitgitgadget/git/pulls/$PR_NUMBER \ |
| 58 | + --jq '"head_sha=\(.head.sha) && repo=\(.base.repo.full_name)"')" |
| 59 | + echo "head_sha=$head_sha" >> $GITHUB_OUTPUT |
| 60 | + echo "repo=$repo" >> $GITHUB_OUTPUT |
| 61 | +
|
| 62 | + export GH_TOKEN="$(case "$repo" in |
| 63 | + gitgitgadget/git) echo "${{ steps.gitgitgadget-git-token.outputs.token }}";; |
| 64 | + git/git) echo "${{ steps.git-git-token.outputs.token }}";; |
| 65 | + dscho/git) echo "${{ steps.dscho-git-token.outputs.token }}";; |
| 66 | + *) echo "${{ secrets.GITHUB_TOKEN }}";; |
| 67 | + esac |
| 68 | + )" |
| 69 | + eval "$(gh api repos/$repo/check-runs -X POST \ |
| 70 | + -f name='handle_pr_comment' \ |
| 71 | + -f head_sha="$head_sha" \ |
| 72 | + -f status='in_progress' \ |
| 73 | + -f details_url="$details_url" \ |
| 74 | + -f "output[title]=$title" \ |
| 75 | + -f "output[summary]=$summary" \ |
| 76 | + -f "output[text]=$text" \ |
| 77 | + --jq '"check_run_id=\(.id)"')" |
| 78 | + echo "check_run_id=$check_run_id" >> $GITHUB_OUTPUT |
42 | 79 | - uses: gitgitgadget/gitgitgadget/handle-pr-comment@v1
|
43 | 80 | with:
|
44 | 81 | pr-repo-token: ${{ steps.gitgitgadget-git-token.outputs.token }}
|
|
48 | 85 |
|
49 | 86 | smtp-pass: "${{ secrets.GITGITGADGET_SMTP_PASS }}"
|
50 | 87 | pr-comment-url: ${{ env.PR_COMMENT_URL }}
|
| 88 | + - name: update the check run |
| 89 | + if: always() && steps.create-check-run.outputs.check_run_id != '' |
| 90 | + run: | |
| 91 | + export GH_TOKEN="$(case "${{ steps.create-check-run.outputs.repo }}" in |
| 92 | + gitgitgadget/git) echo "${{ steps.gitgitgadget-git-token.outputs.token }}";; |
| 93 | + git/git) echo "${{ steps.git-git-token.outputs.token }}";; |
| 94 | + dscho/git) echo "${{ steps.dscho-git-token.outputs.token }}";; |
| 95 | + *) echo "${{ secrets.GITHUB_TOKEN }}";; |
| 96 | + esac |
| 97 | + )" |
| 98 | + gh api repos/${{ steps.create-check-run.outputs.repo }}/check-runs/${{ steps.create-check-run.outputs.check_run_id }} \ |
| 99 | + -X PATCH \ |
| 100 | + -f status='completed' \ |
| 101 | + -f conclusion='${{ job.status }}' \ |
| 102 | + -f 'output[title]=${{ steps.create-check-run.outputs.title }}' \ |
| 103 | + -f 'output[summary]=${{ steps.create-check-run.outputs.summary }}' \ |
| 104 | + -f 'output[text]=${{ steps.create-check-run.outputs.text }}' |
0 commit comments