|
| 1 | +name: Check Depgraph |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: ["CI"] |
| 6 | + types: |
| 7 | + - completed |
| 8 | + |
| 9 | +permissions: |
| 10 | + # Needed in order to leave comments on pull requests. |
| 11 | + pull-requests: "write" |
| 12 | + |
| 13 | +env: |
| 14 | + CARGO_TERM_COLOR: always |
| 15 | + |
| 16 | +jobs: |
| 17 | + check-depgraph: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + if: > |
| 20 | + github.event.workflow_run.event == 'pull_request' && |
| 21 | + github.event.workflow_run.conclusion == 'failure' |
| 22 | + steps: |
| 23 | + - name: Checkout Actions Repository |
| 24 | + uses: actions/checkout@v3 |
| 25 | + |
| 26 | + - name: Download artifact |
| 27 | + id: find-artifact |
| 28 | + uses: actions/github-script@v6 |
| 29 | + with: |
| 30 | + result-encoding: string |
| 31 | + script: | |
| 32 | + var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
| 33 | + owner: context.repo.owner, |
| 34 | + repo: context.repo.repo, |
| 35 | + run_id: ${{ github.event.workflow_run.id }}, |
| 36 | + }); |
| 37 | + var matchArtifacts = artifacts.data.artifacts.filter((artifact) => { |
| 38 | + return artifact.name == "bad-depgraph" |
| 39 | + }); |
| 40 | + if (matchArtifacts.length == 0) { return "false" } |
| 41 | + var matchArtifact = matchArtifacts[0]; |
| 42 | + var download = await github.rest.actions.downloadArtifact({ |
| 43 | + owner: context.repo.owner, |
| 44 | + repo: context.repo.repo, |
| 45 | + artifact_id: matchArtifact.id, |
| 46 | + archive_format: 'zip', |
| 47 | + }); |
| 48 | + var fs = require('fs'); |
| 49 | + fs.writeFileSync('${{github.workspace}}/bad-depgraph.zip', Buffer.from(download.data)); |
| 50 | + return "true" |
| 51 | +
|
| 52 | + - name: Extract artifact |
| 53 | + id: extract_artifact |
| 54 | + if: ${{ steps.find-artifact.outputs.result == 'true' }} |
| 55 | + run: | |
| 56 | + unzip bad-depgraph.zip |
| 57 | + echo "event_number=$(cat event-number)" >> "$GITHUB_OUTPUT" |
| 58 | +
|
| 59 | + - name: Create pull request comment |
| 60 | + uses: marocchino/sticky-pull-request-comment@v2 |
| 61 | + if: ${{ steps.find-artifact.outputs.result == 'true' }} |
| 62 | + with: |
| 63 | + recreate: true |
| 64 | + header: depgraph |
| 65 | + path: pr-comment.txt |
| 66 | + number: ${{ steps.extract_artifact.outputs.event_number }} |
0 commit comments