Skip to content

Commit

Permalink
Fix errors in reporting errors in the "Check changeset vs changed fil…
Browse files Browse the repository at this point in the history
…es" workflow (#7964)
  • Loading branch information
dconeybe committed Jan 19, 2024
1 parent 49c7903 commit 4b5a82e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/check-changeset.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ jobs:
yarn ts-node-script scripts/ci/check_changeset.ts
id: check-changeset
- name: Print changeset checker output
run: echo "${{steps.check-changeset.outputs.CHANGESET_ERROR_MESSAGE}}"
run: |
cat << 'eof_delimiter_that_will_never_occur_in_CHANGESET_ERROR_MESSAGE'
${{steps.check-changeset.outputs.CHANGESET_ERROR_MESSAGE}}
eof_delimiter_that_will_never_occur_in_CHANGESET_ERROR_MESSAGE
- name: Print blocking failure status
run: echo "${{steps.check-changeset.outputs.BLOCKING_FAILURE}}"
- name: Find Comment
Expand Down
18 changes: 15 additions & 3 deletions scripts/ci/check_changeset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import { resolve } from 'path';
import { existsSync } from 'fs';
import { writeFile } from 'fs/promises';
import { exec } from 'child-process-promise';
import chalk from 'chalk';
import simpleGit from 'simple-git';
Expand All @@ -28,6 +29,14 @@ const git = simpleGit(root);
const baseRef = process.env.GITHUB_PULL_REQUEST_BASE_SHA || 'master';
const headRef = process.env.GITHUB_PULL_REQUEST_HEAD_SHA || 'HEAD';

const githubOutputFile = (function (): string {
const value = process.env.GITHUB_OUTPUT;
if (!value) {
throw new Error('GITHUB_OUTPUT environment variable must be set');
}
return value;
})();

// Version bump text converted to rankable numbers.
const bumpRank: Record<string, number> = {
'patch': 0,
Expand Down Expand Up @@ -205,10 +214,13 @@ async function main() {
* step. See:
* https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-output-parameter
*/
if (errors.length > 0)
await exec(
`echo "CHANGESET_ERROR_MESSAGE=${errors.join('%0A')}" >> $GITHUB_OUTPUT`
if (errors.length > 0) {
await writeFile(
githubOutputFile,
`CHANGESET_ERROR_MESSAGE=${errors.join('%0A')}\n`,
{ flag: 'a' }
);
}
process.exit();
}

Expand Down

0 comments on commit 4b5a82e

Please sign in to comment.