From 8c6f7dcb718f9a6a21a0e8bf1575059d2fba7038 Mon Sep 17 00:00:00 2001 From: HarshCasper Date: Sun, 12 Mar 2023 19:34:17 +0530 Subject: [PATCH 1/2] feat: add configuration input and localstack pro usage --- .github/workflows/ci.yml | 4 +++- action.yml | 24 +++++++++++++++++++++--- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44d40f0..99381bf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,6 +13,8 @@ jobs: with: image-tag: 'latest' install-awslocal: 'true' + configuration: DEBUG=1 + use-pro: 'true' env: LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} @@ -20,4 +22,4 @@ jobs: run: | awslocal s3 mb s3://test awslocal s3 ls - echo "Test Execution complete!" + echo "Test Execution complete!" diff --git a/action.yml b/action.yml index fbebce8..4843538 100644 --- a/action.yml +++ b/action.yml @@ -12,9 +12,17 @@ inputs: required: true default: 'latest' install-awslocal: - description: 'Whether to install the `awslocal` CLI into the build environment' + description: 'Whether to install the `awslocal` CLI into the environment' required: true default: 'true' + use-pro: + description: 'Whether to use LocalStack Pro (requires a valid API key)' + required: false + default: 'false' + configuration: + description: 'Configuration variables to use for LocalStack' + required: false + default: '' runs: using: "composite" @@ -22,9 +30,17 @@ runs: - run: | pip install pyopenssl -U - docker pull localstack/localstack:$IMAGE_TAG + + if [ "$USE_PRO" = true ]; then + docker pull localstack/localstack-pro:"$IMAGE_TAG" + CONFIGURATION="$CONFIGURATION DNS_ADDRESS=0" + else + docker pull localstack/localstack:"$IMAGE_TAG" + fi + pip install localstack - localstack start -d + eval "${CONFIGURATION} localstack start -d" + localstack wait -t 30 if [ "$INSTALL_AWSLOCAL" = true ]; then pip install awscli-local[ver1] @@ -33,3 +49,5 @@ runs: env: IMAGE_TAG: "${{ inputs.image-tag }}" INSTALL_AWSLOCAL: "${{ inputs.install-awslocal }}" + USE_PRO: "${{ inputs.use-pro }}" + CONFIGURATION: "${{ inputs.configuration }}" From 86441d6228ffd1faa324da0810143e40693d36f0 Mon Sep 17 00:00:00 2001 From: HarshCasper Date: Sun, 12 Mar 2023 19:49:53 +0530 Subject: [PATCH 2/2] DOCS: Add relevant documentation for new input variables --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 0636b79..1993dc3 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ To get started, you can use this minimal example: ```yml - name: Start LocalStack - uses: HarshCasper/setup-localstack@v0.1.1 + uses: HarshCasper/setup-localstack@v0.1.2 with: image-tag: 'latest' install-awslocal: 'true' @@ -25,10 +25,14 @@ To get started, you can use this minimal example: ### Inputs -|Input|Description |Default -|--|--|--| -|`image-tag` |Tag of the LocalStack Docker image to use |`latest` -|`install-awslocal` |Whether to install the `awslocal` CLI into the build environment | `true` +| Input | Description | Default | +| ------------------ | -------------------------------------------------------------------------------- | -------- | +| `image-tag` | Tag of the LocalStack Docker image to use | `latest` | +| `install-awslocal` | Whether to install the `awslocal` CLI into the build environment | `true` | +| `configuration` | Configuration variables to use while starting LocalStack container | `None` | +| `use-pro` | Whether to use the Pro version of LocalStack (requires API key to be configured) | `false` | + +> **NOTE**: The `LOCALSTACK_API_KEY` environment variable is required to be set if `use-pro` is set to `true`. While starting the [localstack-pro](https://hub.docker.com/r/localstack/localstack-pro) image, the DNS startup is skipped with `DNS_ADDRESS=0` configuration variable. It is required to properly start LocalStack in GitHub Actions runner environment. ### Example workflow @@ -44,10 +48,12 @@ jobs: - uses: actions/checkout@v3 - name: Start LocalStack - uses: HarshCasper/setup-localstack@v0.1.1 + uses: HarshCasper/setup-localstack@v0.1.2 with: image-tag: 'latest' install-awslocal: 'true' + configuration: DEBUG=1 + use-pro: 'true' env: LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}