Files
ruff/.github/workflows/pr-comment.yaml
2023-10-27 12:07:51 -05:00

98 lines
3.1 KiB
YAML

name: PR Check Comment
on:
workflow_run:
workflows: [CI]
types: [completed]
workflow_dispatch:
inputs:
workflow_run_id:
description: The ecosystem workflow that triggers the workflow run
required: true
permissions:
pull-requests: write
jobs:
comment:
runs-on: ubuntu-latest
steps:
- uses: dawidd6/action-download-artifact@v2
name: Download PR Number
with:
name: pr-number
run_id: ${{ github.event.workflow_run.id || github.event.inputs.workflow_run_id }}
if_no_artifact_found: ignore
- name: Extract PR Number
id: pr-number
run: |
if [[ -f pr-number ]]
then
echo "pr-number=$(<pr-number)" >> $GITHUB_OUTPUT
fi
- uses: dawidd6/action-download-artifact@v2
name: "Download ecosystem result for `check`"
id: download-ecosystem-result-check
if: steps.pr-number.outputs.pr-number
with:
name: ecosystem-result-check
workflow: ci.yaml
pr: ${{ steps.pr-number.outputs.pr-number }}
path: pr/ecosystem
if_no_artifact_found: ignore
- uses: dawidd6/action-download-artifact@v2
name: "Download ecosystem result for `format`"
id: download-ecosystem-result-format
if: steps.pr-number.outputs.pr-number
with:
name: ecosystem-result-format
workflow: ci.yaml
pr: ${{ steps.pr-number.outputs.pr-number }}
path: pr/ecosystem
if_no_artifact_found: ignore
- name: Generate `check` ecosystem comment
if: steps.download-ecosystem-result-check.outputs.found_artifact == 'true'
run: |
echo '## Ecosystem results `ruff check`' >> comment.txt
cat pr/ecosystem/ecosystem-result-check >> comment.txt
echo "<br />" >> comment.txt
- name: Generate `format` ecosystem comment
if: steps.download-ecosystem-result-format.outputs.found_artifact == 'true'
run: |
echo '## Ecosystem results `ruff format`' >> comment.txt
cat pr/ecosystem/ecosystem-result-format >> comment.txt
echo "<br />" >> comment.txt
- name: Check comment
run: |
echo $(test -f comment.txt) >> $GITHUB_OUTPUT
# - name: Generate GitHub output
# run: |
# echo 'comment<<EOF' >> $GITHUB_OUTPUT
# cat comment.txt >> $GITHUB_OUTPUT
# echo 'EOF' >> $GITHUB_OUTPUT
- name: Find Comment
uses: peter-evans/find-comment@v2
if: ${{ steps.check-comment.outputs == 'true' }}
id: find-comment
with:
issue-number: ${{ steps.pr-number.outputs.pr-number }}
comment-author: "github-actions[bot]"
body-includes: PR Check Results
- name: Create or update comment
if: steps.find-comment.outcome == 'success'
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ steps.pr-number.outputs.pr-number }}
body-path: comment.txt
edit-mode: replace