Skip to content

Commit

Permalink
Return non-zero response code when an error occurs so dependent workf…
Browse files Browse the repository at this point in the history
…lows will correctly fail (#63)
  • Loading branch information
mangs authored Apr 14, 2024
1 parent 30dee20 commit ce8353f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 23 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 3.0.2

- Return non-zero response code when an error occurs so dependent workflows will correctly fail
- Rename action source directory from `scripts/` to `src/`

## 3.0.1

- Add pull request template
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ inputs:
required: false
runs:
using: node20
main: ./scripts/publishReleaseNotes.mjs
main: ./src/publishReleaseNotes.mjs
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-release-notes-action",
"version": "3.0.1",
"version": "3.0.2",
"author": "Eric L. Goldstein",
"description": "GitHub Action that auto-publishes release notes using a very simple-to-follow set of rules",
"keywords": [
Expand Down Expand Up @@ -28,9 +28,9 @@
"list:eslint:disable-directives": "rg '/(/|\\*+)[ \\t]*eslint-disable[^*]*(\\*+/)?'",
"reinstall": "npm run --silent delete:node_modules && npm run --silent delete:package-lock && npm i",
"reinstall:use-lock-file": "npm run --silent delete:node_modules && npm ci",
"test": "GITHUB_REPOSITORY=mangs/simple-release-notes-action ./scripts/publishReleaseNotes.mjs",
"test": "GITHUB_REPOSITORY=mangs/simple-release-notes-action ./src/publishReleaseNotes.mjs",
"validate:formatting": "prettier --check --no-editorconfig .",
"validate:linting:eslint": "eslint-config-prettier ./scripts/publishReleaseNotes.mjs"
"validate:linting:eslint": "eslint-config-prettier ./src/publishReleaseNotes.mjs"
},
"devDependencies": {
"@babbel/eslint-config": "1.2.2",
Expand Down
16 changes: 11 additions & 5 deletions scripts/publishReleaseNotes.mjs → src/publishReleaseNotes.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const versionMatchRegex =
// Local Functions
function prettyPrintJson(json) {
const prettyString = JSON.stringify(json, undefined, 2);
console.log(prettyString);
console.info(prettyString);
}

// BEGIN EXECUTION
Expand Down Expand Up @@ -101,11 +101,14 @@ try {
method: 'POST',
});
if (response.ok) {
console.log(`✅ SUCCESS CREATING RELEASE: ${tagName}`);
console.info(`✅ SUCCESS CREATING RELEASE: ${tagName}`);
} else {
console.error(`❌ ERROR CREATING RELEASE: ${tagName}`);
}
prettyPrintJson(await response.json());
if (!response.ok) {
process.exit(1); // eslint-disable-line n/no-process-exit -- stack trace not useful here
}
} catch (error) {
console.error('❌❌❌ UNEXPECTED RELEASE ERROR');
throw error;
Expand Down Expand Up @@ -140,10 +143,10 @@ try {
);

if (updateResponse.ok) {
console.log(`✅ SUCCESS UPDATING MAJOR TAG: ${majorTag}`);
console.info(`✅ SUCCESS UPDATING MAJOR TAG: ${majorTag}`);
prettyPrintJson(await updateResponse.json());
} else {
console.log(`🔨 CREATING MAJOR TAG: ${majorTag}`);
console.info(`🔨 CREATING MAJOR TAG: ${majorTag}`);
const createResponse = await fetch(
`https://api.github.com/repos/${repoOwner}/${repoName}/git/refs`,
{
Expand All @@ -157,11 +160,14 @@ try {
},
);
if (createResponse.ok) {
console.log(`✅ SUCCESS CREATING MAJOR TAG: ${majorTag}`);
console.info(`✅ SUCCESS CREATING MAJOR TAG: ${majorTag}`);
} else {
console.error(`❌ ERROR CREATING MAJOR TAG: ${majorTag}`);
}
prettyPrintJson(await createResponse.json());
if (!createResponse.ok) {
process.exit(1); // eslint-disable-line n/no-process-exit -- stack trace not useful here
}
}
} catch (error) {
console.error('❌❌❌ UNEXPECTED TAG ERROR');
Expand Down

0 comments on commit ce8353f

Please sign in to comment.