github/workflows: Fix code size comment workflow for non-PR.
This fixes the case for the code size comment action where there is no matching artifact. Apparently, the result of the github-script action was not treating `false` as a boolean value. To fix the problem we change the result to use string. Also add some logging to make the step a bit less cryptic. Signed-off-by: David Lechner <david@pybricks.com>
This commit is contained in:
parent
3ecbaf1e06
commit
96c23432f6
|
@ -13,6 +13,7 @@ jobs:
|
||||||
id: download-artifact
|
id: download-artifact
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
|
result-encoding: string
|
||||||
script: |
|
script: |
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
|
@ -27,7 +28,10 @@ jobs:
|
||||||
});
|
});
|
||||||
|
|
||||||
if (matchArtifact.length === 0) {
|
if (matchArtifact.length === 0) {
|
||||||
return false;
|
console.log('no matching artifact found');
|
||||||
|
console.log('result: "skip"');
|
||||||
|
|
||||||
|
return 'skip';
|
||||||
}
|
}
|
||||||
|
|
||||||
const download = await github.rest.actions.downloadArtifact({
|
const download = await github.rest.actions.downloadArtifact({
|
||||||
|
@ -39,12 +43,15 @@ jobs:
|
||||||
|
|
||||||
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/code-size-report.zip`, Buffer.from(download.data));
|
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/code-size-report.zip`, Buffer.from(download.data));
|
||||||
|
|
||||||
return true;
|
console.log('artifact downloaded to `code-size-report.zip`');
|
||||||
|
console.log('result: "ok"');
|
||||||
|
|
||||||
|
return 'ok';
|
||||||
- name: 'Unzip artifact'
|
- name: 'Unzip artifact'
|
||||||
if: steps.download-artifact.outputs.result
|
if: steps.download-artifact.outputs.result == 'ok'
|
||||||
run: unzip code-size-report.zip
|
run: unzip code-size-report.zip
|
||||||
- name: Post comment to pull request
|
- name: Post comment to pull request
|
||||||
if: steps.download-artifact.outputs.result
|
if: steps.download-artifact.outputs.result == 'ok'
|
||||||
uses: actions/github-script@v6
|
uses: actions/github-script@v6
|
||||||
with:
|
with:
|
||||||
github-token: ${{secrets.GITHUB_TOKEN}}
|
github-token: ${{secrets.GITHUB_TOKEN}}
|
||||||
|
|
Loading…
Reference in New Issue