diff --git a/README.md b/README.md index 4909dd7..6957a50 100644 --- a/README.md +++ b/README.md @@ -5,21 +5,6 @@ This action allows you to wait for services to become stable **and** retry the w ## Inputs -### `aws-access-key-id` - -**Required** - _string_\ -Your `AWS_ACCESS_KEY_ID`. - -### `aws-secret-access-key` - `` - -**Required** - _string_\ -Your `AWS_SECRET_ACCESS_KEY`. - -### `aws-region` - -**Required** - _string_\ -Your `AWS_REGION`. - ### `ecs-cluster` **Required** - _string_\ @@ -32,9 +17,27 @@ A list of ECS services to make sure are stable. ### `retries` -**Required** - _integer_\ +_Optional_ - _integer_\ The number of times you want to try the stability check. Default `2`. +### `aws-access-key-id` + +_Optional_ - _string_\ +Your AWS ACCESS_KEY_ID.\ +Must be provided as an input / defined as an environment variable. + +### `aws-secret-access-key` + +_Optional_ - _string_\ +Your AWS SECRET_ACCESS_KEY.\ +Must be provided as an input / defined as an environment variable. + +### `aws-region` + +_Optional_ - _string_\ +Your AWS REGION.\ +Must be provided as an input / defined as an environment variable. + ### `verbose` _Optional_ - _boolean_\ @@ -49,8 +52,10 @@ How many retries happened until success. ## Example usage +### Using all available options + ```yaml -uses: oryanmoshe/ecs-wait-action@v1.1 +uses: oryanmoshe/ecs-wait-action@v1.3 with: aws-access-key-id: AKIAIOSFODNN7EXAMPLE aws-secret-access-key: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY @@ -60,3 +65,12 @@ with: retries: 5 verbose: false ``` + +### Minimal configuration + +```yaml +uses: oryanmoshe/ecs-wait-action@v1.3 +with: + ecs-cluster: my-ecs-cluster + ecs-services: '["my-ecs-service-1", "my-ecs-service-2"]' +``` diff --git a/action.yml b/action.yml index c23b53c..07203c2 100644 --- a/action.yml +++ b/action.yml @@ -2,9 +2,14 @@ name: 'ECS Wait' author: 'Oryan Moshe' description: 'Waits for ECS service stability' inputs: + ecs-cluster: + description: 'The ECS cluster name (string)' + required: true + ecs-services: + description: 'List of ECS services to wait for (string[])' + required: true retries: description: 'How many times to retry the 10 minute wait (integer)' - required: true default: 2 aws-access-key-id: description: 'The AWS_ACCESS_KEY_ID (string)' @@ -12,12 +17,6 @@ inputs: description: 'The AWS_SECRET_ACCESS_KEY (string)' aws-region: description: 'The AWS_REGION (string)' - ecs-cluster: - description: 'The ECS cluster name (string)' - required: true - ecs-services: - description: 'List of ECS services to wait for (string[])' - required: true verbose: description: 'Whether to print the retry log (bool)' default: false diff --git a/dist/index.js b/dist/index.js index 24cb92e..775a3d1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5696,28 +5696,42 @@ const createEcsConnection = ({ accessKeyId, secretAccessKey, region }) => region, }); +/** + * Extracts step params from environment and context + * @returns {Object} The params needed to run this action + */ +const extractParams = () => { + const params = { + accessKeyId: + core.getInput('aws-access-key-id') || process.env.AWS_ACCESS_KEY_ID, + secretAccessKey: + core.getInput('aws-secret-access-key') || + process.env.AWS_SECRET_ACCESS_KEY, + region: core.getInput('aws-region') || process.env.AWS_REGION, + retries: parseInt(core.getInput('retries'), 10), + cluster: core.getInput('ecs-cluster'), + services: JSON.parse(core.getInput('ecs-services')), + verbose: core.getInput('verbose') === 'true', + }; + + if (!params.accessKeyId || !params.secretAccessKey || !params.region) { + core.setFailed( + 'AWS credentials were not found in inputs or environment variables.' + ); + return null; + } + + return params; +}; + /** * The GitHub Action entry point. */ const main = async () => { try { - const params = { - accessKeyId: - core.getInput('aws-access-key-id') || process.env.AWS_ACCESS_KEY_ID, - secretAccessKey: - core.getInput('aws-secret-access-key') || - process.env.AWS_SECRET_ACCESS_KEY, - region: core.getInput('aws-region') || process.env.AWS_REGION, - retries: parseInt(core.getInput('retries'), 10), - cluster: core.getInput('ecs-cluster'), - services: JSON.parse(core.getInput('ecs-services')), - verbose: core.getInput('verbose') === 'true', - }; + const params = extractParams(); - if (!params.accessKeyId || !params.secretAccessKey || !params.region) { - core.setFailed( - 'AWS credentials were not found in inputs or environment variables.' - ); + if (!params) { return; } diff --git a/src/index.js b/src/index.js index ff783e1..8c2af4d 100644 --- a/src/index.js +++ b/src/index.js @@ -58,28 +58,42 @@ const createEcsConnection = ({ accessKeyId, secretAccessKey, region }) => region, }); +/** + * Extracts step params from environment and context + * @returns {Object} The params needed to run this action + */ +const extractParams = () => { + const params = { + accessKeyId: + core.getInput('aws-access-key-id') || process.env.AWS_ACCESS_KEY_ID, + secretAccessKey: + core.getInput('aws-secret-access-key') || + process.env.AWS_SECRET_ACCESS_KEY, + region: core.getInput('aws-region') || process.env.AWS_REGION, + retries: parseInt(core.getInput('retries'), 10), + cluster: core.getInput('ecs-cluster'), + services: JSON.parse(core.getInput('ecs-services')), + verbose: core.getInput('verbose') === 'true', + }; + + if (!params.accessKeyId || !params.secretAccessKey || !params.region) { + core.setFailed( + 'AWS credentials were not found in inputs or environment variables.' + ); + return null; + } + + return params; +}; + /** * The GitHub Action entry point. */ const main = async () => { try { - const params = { - accessKeyId: - core.getInput('aws-access-key-id') || process.env.AWS_ACCESS_KEY_ID, - secretAccessKey: - core.getInput('aws-secret-access-key') || - process.env.AWS_SECRET_ACCESS_KEY, - region: core.getInput('aws-region') || process.env.AWS_REGION, - retries: parseInt(core.getInput('retries'), 10), - cluster: core.getInput('ecs-cluster'), - services: JSON.parse(core.getInput('ecs-services')), - verbose: core.getInput('verbose') === 'true', - }; + const params = extractParams(); - if (!params.accessKeyId || !params.secretAccessKey || !params.region) { - core.setFailed( - 'AWS credentials were not found in inputs or environment variables.' - ); + if (!params) { return; }