|
| 1 | +name: Comment on test ALL PR |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_run: |
| 5 | + workflows: |
| 6 | + - "Test" |
| 7 | + types: |
| 8 | + - completed |
| 9 | + |
| 10 | +jobs: |
| 11 | + comment: |
| 12 | + timeout-minutes: 30 |
| 13 | + runs-on: ubuntu-latest |
| 14 | + if: > |
| 15 | + (github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'workflow_run') && |
| 16 | + github.event.workflow_run.conclusion == 'success' |
| 17 | + steps: |
| 18 | + - name: Download Artifacts |
| 19 | + uses: actions/github-script@v7 |
| 20 | + id: download_artifacts |
| 21 | + with: |
| 22 | + script: | |
| 23 | + var prArtifactInfo = await github.rest.actions.listWorkflowRunArtifacts({ |
| 24 | + owner: context.repo.owner, |
| 25 | + repo: context.repo.repo, |
| 26 | + run_id: ${{ github.event.workflow_run.id }}, |
| 27 | + name: 'pr' |
| 28 | + }); |
| 29 | + var prArtifact = prArtifactInfo.data.artifacts.filter((artifact) => { |
| 30 | + return artifact.name == "pr" |
| 31 | + })[0]; |
| 32 | + var downloadedPrArtifact = await github.rest.actions.downloadArtifact({ |
| 33 | + owner: context.repo.owner, |
| 34 | + repo: context.repo.repo, |
| 35 | + artifact_id: prArtifact.id, |
| 36 | + archive_format: 'zip', |
| 37 | + }); |
| 38 | + var fs = require('fs'); |
| 39 | + fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(downloadedPrArtifact.data)); |
| 40 | +
|
| 41 | + var resultArtifactInfo = await github.rest.actions.listWorkflowRunArtifacts({ |
| 42 | + owner: context.repo.owner, |
| 43 | + repo: context.repo.repo, |
| 44 | + run_id: ${{ github.event.workflow_run.id }}, |
| 45 | + name: 'results.md' |
| 46 | + }); |
| 47 | + var compatibilityResult = resultArtifactInfo.data.artifacts.filter((artifact) => { |
| 48 | + return artifact.name.startsWith("results") && artifact.name.endsWith(".md") |
| 49 | + })[0]; |
| 50 | + var downloadedResultsArtifact = await github.rest.actions.downloadArtifact({ |
| 51 | + owner: context.repo.owner, |
| 52 | + repo: context.repo.repo, |
| 53 | + artifact_id: compatibilityResult.id, |
| 54 | + archive_format: 'zip', |
| 55 | + }); |
| 56 | + fs.writeFileSync('${{github.workspace}}/results.zip', Buffer.from(downloadedResultsArtifact.data)); |
| 57 | +
|
| 58 | + core.setOutput('results_file_name', compatibilityResult.name); |
| 59 | + - name: Unpack artifacts |
| 60 | + run: | |
| 61 | + unzip pr.zip |
| 62 | + unzip results.zip |
| 63 | + - name: Comment on PR |
| 64 | + uses: actions/github-script@v7 |
| 65 | + with: |
| 66 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + script: | |
| 68 | + const fs = require('fs'); |
| 69 | + var issue_number = Number(fs.readFileSync('./pr_info')); |
| 70 | + const results = fs.readFileSync('${{ steps.download_artifacts.outputs.results_file_name }}', 'utf-8'); |
| 71 | + const commentBody = `## Apollo Federation Subgraph Compatibility Results\n${results}\n`; |
| 72 | + github.rest.issues.createComment({ |
| 73 | + issue_number: issue_number, |
| 74 | + owner: context.repo.owner, |
| 75 | + repo: context.repo.repo, |
| 76 | + body: commentBody |
| 77 | + }); |
0 commit comments