Comment metrics #6
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 metrics | |
# read-write repo token | |
on: | |
workflow_run: | |
workflows: [Build metrics] | |
types: [completed] | |
jobs: | |
comment-binary-size: | |
runs-on: ${{ (github.repository == 'numworks/epsilon-internal') && 'self-hosted' || 'ubuntu-latest' }} | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
steps: | |
- name: Download metrics summary | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
run_id: ${{github.event.workflow_run.id }}, | |
}); | |
var matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
return artifact.name == "metrics-output" | |
})[0]; | |
var download = await github.rest.actions.downloadArtifact({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
artifact_id: matchArtifact.id, | |
archive_format: 'zip', | |
}); | |
var fs = require('fs'); | |
fs.writeFileSync('${{github.workspace}}/metrics-output.zip', Buffer.from(download.data)); | |
- name: Unzip file | |
run: sudo apt-get install unzip && unzip metrics-output.zip | |
- name: Add comment | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
var fs = require('fs'); | |
var pr_number = Number(fs.readFileSync('./PR_number')); | |
var binary_size_summary = fs.readFileSync('./binary_size_summary'); | |
var app_sizes = fs.readFileSync('./app_sizes'); | |
var binary_size_n0110 = fs.readFileSync('./binary_size_n0110'); | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: pr_number, | |
body: "### Binary size analysis\n\n" + binary_size_summary + "\n<details>\n<summary>Full details</summary>\n\n### Apps\n\n" + app_sizes + "\n\n### N0110\n\n" + binary_size_n0110 + "</details>", | |
}); |