Comment on test ALL PR #158
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Comment on test ALL PR | |
on: | |
workflow_run: | |
workflows: | |
- "Test" | |
types: | |
- completed | |
jobs: | |
comment: | |
timeout-minutes: 30 | |
runs-on: ubuntu-latest | |
if: > | |
(github.event.workflow_run.event == 'pull_request' || github.event.workflow_run.event == 'workflow_run') && | |
github.event.workflow_run.conclusion == 'success' | |
steps: | |
- name: Download Artifacts | |
uses: actions/github-script@v7 | |
id: download_artifacts | |
with: | |
script: | | |
var prArtifactInfo = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{ github.event.workflow_run.id }}, | |
name: 'pr' | |
}); | |
var prArtifact = prArtifactInfo.data.artifacts.filter((artifact) => { | |
return artifact.name == "pr" | |
})[0]; | |
var downloadedPrArtifact = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: prArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(downloadedPrArtifact.data)); | |
var resultArtifactInfo = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{ github.event.workflow_run.id }}, | |
name: 'results.md' | |
}); | |
var compatibilityResult = resultArtifactInfo.data.artifacts.filter((artifact) => { | |
return artifact.name.startsWith("results") && artifact.name.endsWith(".md") | |
})[0]; | |
var downloadedResultsArtifact = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: compatibilityResult.id, | |
archive_format: 'zip', | |
}); | |
fs.writeFileSync('${{github.workspace}}/results.zip', Buffer.from(downloadedResultsArtifact.data)); | |
core.setOutput('results_file_name', compatibilityResult.name); | |
- name: Unpack artifacts | |
run: | | |
unzip pr.zip | |
unzip results.zip | |
- name: Comment on PR | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
var issue_number = Number(fs.readFileSync('./pr_info')); | |
const results = fs.readFileSync('${{ steps.download_artifacts.outputs.results_file_name }}', 'utf-8'); | |
const commentBody = `## Apollo Federation Subgraph Compatibility Results\n${results}\n`; | |
github.rest.issues.createComment({ | |
issue_number: issue_number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: commentBody | |
}); |