Skip to content
Open
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
5 changes: 3 additions & 2 deletions .github/scripts/check-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ exists=$(

if [[ "$exists" == true ]]; then
echo "Release ${release_version} already exists."
echo '::set-output name=release_exists::true'
echo "release_exists=true" >>"$GITHUB_OUTPUT"
else
echo '::set-output name=release_exists::false'
echo "release_exists=false" >>"$GITHUB_OUTPUT"

fi
2 changes: 1 addition & 1 deletion .github/scripts/source-tag-sha.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ if [[ $sha == 'null' ]]; then
fi

echo "SHA for ${tag_name}: ${sha}"
echo "::set-output name=sha::$sha"
echo "sha=${sha}" >>"$GITHUB_OUTPUT"
12 changes: 6 additions & 6 deletions .github/workflows/build-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
name: Build
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- name: Install dependencies
run: npm install
Expand All @@ -39,14 +39,14 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Get version
id: get-version
run: |
version=$(cat package.json | jq '.version' --raw-output)
echo "Version: v${version}"
echo "::set-output name=version::v${version}"
echo "version=v${version}" >> "$GITHUB_OUTPUT"

- name: Check if release exists
id: release-check
Expand All @@ -71,7 +71,7 @@ jobs:
if: needs.release-check.outputs.release_exists == 'false'
steps:
- name: Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
with:
name: ${{ needs.release-check.outputs.version }}
tag_name: ${{ needs.release-check.outputs.version }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/feature-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ jobs:
name: Build
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 16
node-version: 20

- name: Install dependencies
run: npm install
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/major-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ jobs:
environment: major-release-update
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Get major release version
id: get-major-version
run: |
echo "Tag name: ${TAG_NAME}"
major_version=${TAG_NAME%.*.*}
echo "Major Version: ${major_version}"
echo "::set-output name=major_version::$major_version"
echo "major_version=${major_version}" >> "$GITHUB_OUTPUT"

- name: Check if major version exists
id: check-release
Expand All @@ -56,7 +56,7 @@ jobs:
${{ secrets.GITHUB_TOKEN }}

- name: Create Major Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: steps.check-release.outputs.release_exists == 'false'
id: create_release
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
name: Test Linux
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ outputs:
description: "Execution command ID generated by AWS send command API"

runs:
using: "node16"
using: "node20"
main: "dist/index.js"
59 changes: 37 additions & 22 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,6 @@ const file_command_1 = __nccwpck_require__(717);
const utils_1 = __nccwpck_require__(5278);
const os = __importStar(__nccwpck_require__(22037));
const path = __importStar(__nccwpck_require__(71017));
const uuid_1 = __nccwpck_require__(75840);
const oidc_utils_1 = __nccwpck_require__(98041);
/**
* The code to exit an action
Expand Down Expand Up @@ -170,20 +169,9 @@ function exportVariable(name, val) {
process.env[name] = convertedVal;
const filePath = process.env['GITHUB_ENV'] || '';
if (filePath) {
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
// These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter.
if (name.includes(delimiter)) {
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
}
if (convertedVal.includes(delimiter)) {
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
}
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
file_command_1.issueCommand('ENV', commandValue);
}
else {
command_1.issueCommand('set-env', { name }, convertedVal);
return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val));
}
command_1.issueCommand('set-env', { name }, convertedVal);
}
exports.exportVariable = exportVariable;
/**
Expand All @@ -201,7 +189,7 @@ exports.setSecret = setSecret;
function addPath(inputPath) {
const filePath = process.env['GITHUB_PATH'] || '';
if (filePath) {
file_command_1.issueCommand('PATH', inputPath);
file_command_1.issueFileCommand('PATH', inputPath);
}
else {
command_1.issueCommand('add-path', {}, inputPath);
Expand Down Expand Up @@ -241,7 +229,10 @@ function getMultilineInput(name, options) {
const inputs = getInput(name, options)
.split('\n')
.filter(x => x !== '');
return inputs;
if (options && options.trimWhitespace === false) {
return inputs;
}
return inputs.map(input => input.trim());
}
exports.getMultilineInput = getMultilineInput;
/**
Expand Down Expand Up @@ -274,8 +265,12 @@ exports.getBooleanInput = getBooleanInput;
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput(name, value) {
const filePath = process.env['GITHUB_OUTPUT'] || '';
if (filePath) {
return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value));
}
process.stdout.write(os.EOL);
command_1.issueCommand('set-output', { name }, value);
command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value));
}
exports.setOutput = setOutput;
/**
Expand Down Expand Up @@ -404,7 +399,11 @@ exports.group = group;
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function saveState(name, value) {
command_1.issueCommand('save-state', { name }, value);
const filePath = process.env['GITHUB_STATE'] || '';
if (filePath) {
return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value));
}
command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value));
}
exports.saveState = saveState;
/**
Expand Down Expand Up @@ -470,13 +469,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result;
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.issueCommand = void 0;
exports.prepareKeyValueMessage = exports.issueFileCommand = void 0;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(__nccwpck_require__(57147));
const os = __importStar(__nccwpck_require__(22037));
const uuid_1 = __nccwpck_require__(75840);
const utils_1 = __nccwpck_require__(5278);
function issueCommand(command, message) {
function issueFileCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`);
Expand All @@ -488,7 +488,22 @@ function issueCommand(command, message) {
encoding: 'utf8'
});
}
exports.issueCommand = issueCommand;
exports.issueFileCommand = issueFileCommand;
function prepareKeyValueMessage(key, value) {
const delimiter = `ghadelimiter_${uuid_1.v4()}`;
const convertedValue = utils_1.toCommandValue(value);
// These should realistically never happen, but just in case someone finds a
// way to exploit uuid generation let's not allow keys or values that contain
// the delimiter.
if (key.includes(delimiter)) {
throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`);
}
if (convertedValue.includes(delimiter)) {
throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`);
}
return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`;
}
exports.prepareKeyValueMessage = prepareKeyValueMessage;
//# sourceMappingURL=file-command.js.map

/***/ }),
Expand Down Expand Up @@ -543,7 +558,7 @@ class OidcClient {
.catch(error => {
throw new Error(`Failed to get ID Token. \n
Error Code : ${error.statusCode}\n
Error Message: ${error.result.message}`);
Error Message: ${error.message}`);
});
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
if (!id_token) {
Expand Down
54 changes: 36 additions & 18 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
},
"homepage": "https://github.com/debugger24/action-aws-ssm-run-command#readme",
"dependencies": {
"@actions/core": "^1.9.1",
"@actions/core": "^1.10.1",
"@aws-sdk/client-ssm": "^3.154.0"
},
"devDependencies": {
"@types/node": "^18.7.11",
"@types/node": "^20.12.2",
"@vercel/ncc": "^0.34.0",
"typescript": "^4.7.4"
}
Expand Down