diff --git a/.github/scripts/check-release.sh b/.github/scripts/check-release.sh index 1f43668..cad6161 100755 --- a/.github/scripts/check-release.sh +++ b/.github/scripts/check-release.sh @@ -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 diff --git a/.github/scripts/source-tag-sha.sh b/.github/scripts/source-tag-sha.sh index 6b9119c..522ed2d 100755 --- a/.github/scripts/source-tag-sha.sh +++ b/.github/scripts/source-tag-sha.sh @@ -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" diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 7c71c9e..822a6d3 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -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 @@ -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 @@ -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 }} diff --git a/.github/workflows/feature-branch.yaml b/.github/workflows/feature-branch.yaml index 4402165..43beb4c 100644 --- a/.github/workflows/feature-branch.yaml +++ b/.github/workflows/feature-branch.yaml @@ -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 diff --git a/.github/workflows/major-release.yaml b/.github/workflows/major-release.yaml index 73d56ed..ab56489 100644 --- a/.github/workflows/major-release.yaml +++ b/.github/workflows/major-release.yaml @@ -29,7 +29,7 @@ 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 @@ -37,7 +37,7 @@ jobs: 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 @@ -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: diff --git a/.github/workflows/test-branch.yaml b/.github/workflows/test-branch.yaml index f7562cc..e208ab0 100644 --- a/.github/workflows/test-branch.yaml +++ b/.github/workflows/test-branch.yaml @@ -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: diff --git a/action.yml b/action.yml index 50ca188..17daaae 100644 --- a/action.yml +++ b/action.yml @@ -35,5 +35,5 @@ outputs: description: "Execution command ID generated by AWS send command API" runs: - using: "node16" + using: "node20" main: "dist/index.js" diff --git a/dist/index.js b/dist/index.js index 0bb4bea..cec80e7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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 @@ -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; /** @@ -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); @@ -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; /** @@ -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; /** @@ -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; /** @@ -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}`); @@ -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 /***/ }), @@ -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) { diff --git a/package-lock.json b/package-lock.json index 7c83d34..afdc443 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,27 +1,27 @@ { "name": "action-aws-ssm-run-command", - "version": "0.1.0", + "version": "1.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "action-aws-ssm-run-command", - "version": "0.1.0", + "version": "1.0.1", "license": "Apache-2.0", "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" } }, "node_modules/@actions/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", - "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz", + "integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==", "dependencies": { "@actions/http-client": "^2.0.1", "uuid": "^8.3.2" @@ -903,10 +903,13 @@ } }, "node_modules/@types/node": { - "version": "18.7.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.11.tgz", - "integrity": "sha512-KZhFpSLlmK/sdocfSAjqPETTMd0ug6HIMIAwkwUpU79olnZdQtMxpQP+G1wDzCH7na+FltSIhbaZuKdwZ8RDrw==", - "dev": true + "version": "20.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", + "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", + "dev": true, + "dependencies": { + "undici-types": "~5.26.4" + } }, "node_modules/@vercel/ncc": { "version": "0.34.0", @@ -968,6 +971,12 @@ "node": ">=4.2.0" } }, + "node_modules/undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "node_modules/uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", @@ -979,9 +988,9 @@ }, "dependencies": { "@actions/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", - "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz", + "integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==", "requires": { "@actions/http-client": "^2.0.1", "uuid": "^8.3.2" @@ -1721,10 +1730,13 @@ } }, "@types/node": { - "version": "18.7.11", - "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.11.tgz", - "integrity": "sha512-KZhFpSLlmK/sdocfSAjqPETTMd0ug6HIMIAwkwUpU79olnZdQtMxpQP+G1wDzCH7na+FltSIhbaZuKdwZ8RDrw==", - "dev": true + "version": "20.12.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.7.tgz", + "integrity": "sha512-wq0cICSkRLVaf3UGLMGItu/PtdY7oaXaI/RVU+xliKVOtRna3PRY57ZDfztpDL0n11vfymMUnXv8QwYCO7L1wg==", + "dev": true, + "requires": { + "undici-types": "~5.26.4" + } }, "@vercel/ncc": { "version": "0.34.0", @@ -1763,6 +1775,12 @@ "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", "dev": true }, + "undici-types": { + "version": "5.26.5", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz", + "integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==", + "dev": true + }, "uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", diff --git a/package.json b/package.json index ad63b1e..b8a961c 100644 --- a/package.json +++ b/package.json @@ -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" }