mirror of
https://github.com/boykopovar/AnyPS5.git
synced 2026-11-08 13:50:20 +00:00
50 lines
2.0 KiB
YAML
50 lines
2.0 KiB
YAML
name: Progress comment
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows: [Progress report]
|
|
types: [completed]
|
|
|
|
permissions:
|
|
actions: read
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
comment:
|
|
if: github.event.workflow_run.conclusion == 'success'
|
|
runs-on: ubuntu-latest
|
|
concurrency:
|
|
group: progress-comment-${{ github.event.workflow_run.head_sha }}-${{ github.event.workflow_run.pull_requests[0].number || github.event.workflow_run.id }}
|
|
cancel-in-progress: true
|
|
timeout-minutes: 15
|
|
steps:
|
|
- uses: actions/download-artifact@v8
|
|
with:
|
|
name: progress-report
|
|
run-id: ${{ github.event.workflow_run.id }}
|
|
github-token: ${{ github.token }}
|
|
- env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
GH_REPO: ${{ github.repository }}
|
|
RUN_SHA: ${{ github.event.workflow_run.head_sha }}
|
|
RUN_REF: ${{ github.event.workflow_run.head_branch }}
|
|
RUN_REPO: ${{ github.event.workflow_run.head_repository.full_name }}
|
|
run: |
|
|
pr=$(cat pr)
|
|
[[ $pr =~ ^[0-9]+$ ]] || exit 1
|
|
identity=$(gh pr view "$pr" --json headRefOid,headRefName,headRepositoryOwner,headRepository --jq '[.headRefOid, .headRefName, .headRepositoryOwner.login + "/" + .headRepository.name] | @tsv') || identity=""
|
|
[ "$identity" = "$(printf '%s\t%s\t%s' "$RUN_SHA" "$RUN_REF" "$RUN_REPO")" ] || exit 0
|
|
marker='<!-- progress-report -->'
|
|
id=$(gh api "repos/$GH_REPO/issues/$pr/comments" --paginate \
|
|
--jq ".[] | select(.user.login == \"github-actions[bot]\" and (.body | startswith(\"$marker\"))) | .id" | head -n1)
|
|
if [ -f report.md ]; then
|
|
printf '%s\n%s' "$marker" "$(cat report.md)" > body.md
|
|
if [ -n "$id" ]; then
|
|
gh api -X PATCH "repos/$GH_REPO/issues/comments/$id" -F [email protected] > /dev/null
|
|
else
|
|
gh pr comment "$pr" --body-file body.md
|
|
fi
|
|
elif [ -n "$id" ]; then
|
|
gh api -X DELETE "repos/$GH_REPO/issues/comments/$id"
|
|
fi
|