Annotate "added thermo lib for spcs in core GA calculated in CC" #819
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: Annotate pull request with regression summaries | |
# Takes a regression summary from a workflow run and annotates the pull request with it | |
# The pull request number is taken from the first line of the summary.txt file. | |
# The summary file is in an artifact called regression_summary associated | |
# with the workflow run that triggered this workflow. | |
# based on https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow | |
on: | |
workflow_run: | |
workflows: | |
- Continuous Integration | |
types: | |
- completed | |
run-name: Annotate "${{ github.event.workflow_run.display_title }}" | |
jobs: | |
on-success: | |
runs-on: ubuntu-latest | |
if: ${{ github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'pull_request' }} | |
steps: | |
- run: echo 'The triggering workflow passed' | |
- name: 'Download regression_summary artifact' | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: context.payload.workflow_run.id, | |
}); | |
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "regression_summary" | |
})[0]; | |
let download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
let fs = require('fs'); | |
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/regression_summary.zip`, Buffer.from(download.data)); | |
- name: 'Unzip artifact' | |
run: unzip regression_summary.zip | |
- name: 'Get pull request number' | |
run: | | |
echo "PR_NUMBER=$( head -n 1 summary.txt )" >> $GITHUB_ENV | |
# remove the first line from the file | |
sed -i '1d' summary.txt | |
- name: Write summary to pull request as a comment | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
filePath: summary.txt | |
pr_number: ${{ env.PR_NUMBER }} | |
- name: Report the github.event.workflow_run as json | |
if: ${{ failure() }} | |
run: echo $JSON | |
env: | |
JSON: ${{ toJson(github.event.workflow_run) }} |