Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exit immediatly when retention-days and compression-level are not numeric #5

Merged
merged 1 commit into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 31 additions & 67 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { readFileSync } from 'fs';
import { debug, getInput, setOutput, setFailed, startGroup, endGroup } from '@actions/core';
import { exit } from 'process';
import { debug, getInput, setOutput, setFailed } from '@actions/core';
import { DefaultArtifactClient } from '@actions/artifact';

function getIntInput(key) {
const inputStr = getInput(key)
if (!inputStr) {
setFailed(`Invalid ${key}: Blank value`)
exit()
}
const inputInt = parseInt(inputStr)
if (isNaN(inputInt)) {
setFailed(`Invalid ${key}: Not a number`)
exit()
}
return inputInt
}

async function run() {
try {
startGroup('Do some function')
const name = getInput('name');
debug(`Name: ${name}`);
const dist = getInput('dist');
Expand All @@ -27,7 +29,6 @@ async function run() {
debug(`Retention Days: ${retentionDays}`);
const compressionLevel = getIntInput('compression-level');
debug(`Compression Level: ${compressionLevel}`);
endGroup()

debug(`Parsing ${dist}/artifacts.json`)
const artifacts = JSON.parse(
Expand Down