diff --git a/action.yml b/action.yml index 462ef60..4561066 100644 --- a/action.yml +++ b/action.yml @@ -39,41 +39,23 @@ inputs: runs: using: "composite" steps: - - name: Initial PR comment - # TODO: potentially replace with Action version number over time - uses: LocalStack/setup-localstack/prepare@main - if: inputs.ci-project && inputs.github-token - with: - github-token: ${{ inputs.github-token }} - ci-project: ${{ inputs.ci-project }} - - - name: Start LocalStack - run: | - pip install pyopenssl -U - - if [ "$USE_PRO" = true ]; then - docker pull localstack/localstack-pro:"$IMAGE_TAG" & - CONFIGURATION="$CONFIGURATION DNS_ADDRESS=127.0.0.1" - else - docker pull localstack/localstack:"$IMAGE_TAG" & - fi - - pip install localstack - if [ "$INSTALL_AWSLOCAL" = true ]; then - pip install awscli-local[ver1] - fi - - export CI_PROJECT=${{ inputs.ci-project }} - eval "${CONFIGURATION} localstack start -d" - - localstack wait -t 30 - - shell: bash + # - name: Initial PR comment + # # TODO: potentially replace with Action version number over time + # uses: LocalStack/setup-localstack/prepare@main + # if: inputs.ci-project && inputs.github-token + # with: + # github-token: ${{ inputs.github-token }} + # ci-project: ${{ inputs.ci-project }} + + - name: Start Localstack + uses: jenseng/dynamic-uses@v1 env: - IMAGE_TAG: "${{ inputs.image-tag }}" - INSTALL_AWSLOCAL: "${{ inputs.install-awslocal }}" - USE_PRO: "${{ inputs.use-pro }}" - CONFIGURATION: "${{ inputs.configuration }}" + action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} + with: + # now you can use expressions 🥳 + uses: LocalStack/setup-localstack/startup@${{ env.action-version }} + # the `with` needs to be converted to a valid json string + with: "${{ toJSON(inputs) }}" # TODO: potentially add an additional step here to create preview envs, and add a switch to # enable/disable the "Start LocalStack" action above. This way we could make this action diff --git a/startup/action.yml b/startup/action.yml new file mode 100644 index 0000000..861e806 --- /dev/null +++ b/startup/action.yml @@ -0,0 +1,67 @@ +name: 'Start up Localstack' + +inputs: + image-tag: + description: 'Tag of the LocalStack Docker image to use' + required: true + default: 'latest' + install-awslocal: + 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: '' + ci-project: + description: 'Name of the CI project to track in LocalStack Cloud' + required: false + default: '' + +runs: + using: "composite" + steps: + # - name: Initial PR comment + # # TODO: potentially replace with Action version number over time + # uses: LocalStack/setup-localstack/prepare@main + # if: inputs.ci-project && inputs.github-token + # with: + # github-token: ${{ inputs.github-token }} + # ci-project: ${{ inputs.ci-project }} + + - name: Start LocalStack + run: | + pip install pyopenssl -U + + if [ "$USE_PRO" = true ]; then + docker pull localstack/localstack-pro:"$IMAGE_TAG" & + CONFIGURATION="$CONFIGURATION DNS_ADDRESS=127.0.0.1" + else + docker pull localstack/localstack:"$IMAGE_TAG" & + fi + + pip install localstack + if [ "$INSTALL_AWSLOCAL" = true ]; then + pip install awscli-local[ver1] + fi + + export CI_PROJECT=${{ inputs.ci-project }} + eval "${CONFIGURATION} localstack start -d" + + localstack wait -t 30 + + shell: bash + env: + IMAGE_TAG: "${{ inputs.image-tag }}" + INSTALL_AWSLOCAL: "${{ inputs.install-awslocal }}" + USE_PRO: "${{ inputs.use-pro }}" + CONFIGURATION: "${{ inputs.configuration }}" + + # TODO: potentially add an additional step here to create preview envs, and add a switch to + # enable/disable the "Start LocalStack" action above. This way we could make this action + # the single entry point which then delegates to sub-actions in this repo, based on the + # user-provided configuration...