From bb050f60f1cd47b67a50e405749e9ff108397433 Mon Sep 17 00:00:00 2001 From: lakkeger Date: Thu, 16 May 2024 18:57:36 +0200 Subject: [PATCH] fix: fix sub-action versions --- .github/workflows/ci.yml | 76 +++++++++++++++++++++++++++------------- action.yml | 28 ++++++--------- startup/action.yml | 9 ++--- 3 files changed, 65 insertions(+), 48 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0f4ea53..43ecd8a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -19,15 +19,21 @@ jobs: steps: - uses: actions/checkout@v3 + # We must hack the action call as remote to be able to use the relative paths - name: Start LocalStack - uses: ./ + uses: jenseng/dynamic-uses@v1 with: - image-tag: 'latest' - install-awslocal: 'true' - configuration: DEBUG=1 - use-pro: 'true' + uses: LocalStack/setup-localstack@${{ env.action-version }} + with: |- + { + "image-tag": "latest", + "install-awslocal": "true", + "configuration": "DEBUG=1", + "use-pro": "true", + } env: LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} - name: Run Tests against LocalStack run: | @@ -43,13 +49,19 @@ jobs: uses: actions/checkout@v3 - name: Start LocalStack - uses: ./ + uses: jenseng/dynamic-uses@v1 with: - image-tag: 'latest' - install-awslocal: 'true' - use-pro: 'true' + uses: LocalStack/setup-localstack@${{ env.action-version }} + with: |- + { + "image-tag": "latest", + "install-awslocal": "true", + "configuration": "DEBUG=1", + "use-pro": "true", + } env: LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} - name: Run AWS commands run: | @@ -57,13 +69,18 @@ jobs: awslocal sqs create-queue --queue-name test-queue - name: Save the Cloud Pod - uses: ./ + uses: jenseng/dynamic-uses@v1 with: - state-name: cloud-pods-test - state-action: save - skip-startup: 'true' + uses: LocalStack/setup-localstack@${{ env.action-version }} + with: |- + { + "state-name": "cloud-pods-test", + "state-action": "save", + "skip-startup": "true", + } env: LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} local-state-test: name: 'Test Local State Action' @@ -73,25 +90,36 @@ jobs: uses: actions/checkout@v3 - name: Start LocalStack - uses: ./ + uses: jenseng/dynamic-uses@v1 with: - image-tag: 'latest' - install-awslocal: 'true' - use-pro: 'true' + uses: LocalStack/setup-localstack@${{ env.action-version }} + with: |- + { + "image-tag": "latest", + "install-awslocal": "true", + "configuration": "DEBUG=1", + "use-pro": "true", + } env: LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} - name: Run AWS commands run: | awslocal s3 mb s3://test awslocal sqs create-queue --queue-name test-queue - - name: Save the State into Artifact - uses: ./ + - name: Save the Cloud Pod + uses: jenseng/dynamic-uses@v1 with: - state-name: state-test - state-action: save - state-backend: local - skip-startup: 'true' + uses: LocalStack/setup-localstack@${{ env.action-version }} + with: |- + { + "state-name": "cloud-pods-test", + "state-action": "save", + "state-backend": "local", + "skip-startup": "true", + } env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} \ No newline at end of file + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} diff --git a/action.yml b/action.yml index 6c44a99..0396f5b 100644 --- a/action.yml +++ b/action.yml @@ -72,13 +72,14 @@ inputs: runs: using: "composite" steps: + - run: echo "action-root=$(ls -d ./../../_actions/LocalStack/setup-localstack/*)" >> $GITHUB_ENV + shell: bash + - name: Install tools uses: jenseng/dynamic-uses@v1 if: ${{ inputs.skip-startup == 'true' || inputs.state-backend == 'preview' }} - env: - action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} with: - uses: LocalStack/setup-localstack/tools@${{ env.action-version }} + uses: ${{ env.action-root }}/tools with: |- { "install-awslocal": "${{ inputs.install-awslocal }}", @@ -87,11 +88,9 @@ runs: - name: Start Localstack uses: jenseng/dynamic-uses@v1 if: ${{ inputs.skip-startup != 'true' && inputs.state-backend != 'preview' }} - env: - action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} with: - # now we can dynamically determine sub-action versions 🥳 - uses: LocalStack/setup-localstack/startup@${{ env.action-version }} + # now we can dynamically determine sub-action path 🥳 + uses: ${{ env.action-root }}/startup # the `with` needs to be converted to a valid json string # keeping in there install-awslocal for backward compatibility with: |- @@ -108,10 +107,8 @@ runs: - name: Manage state if: ${{ inputs.state-action == 'save' || inputs.state-action == 'load' }} uses: jenseng/dynamic-uses@v1 - env: - action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} with: - uses: LocalStack/setup-localstack/${{ inputs.state-backend }}@${{ env.action-version }} + uses: ${{ env.action-root }}/${{ inputs.state-backend }} with: |- { "name": "${{ inputs.state-name }}", @@ -121,10 +118,8 @@ runs: - name: Create Ephemeral Instance if: ${{ inputs.state-action == 'start' && inputs.state-backend == 'preview' }} uses: jenseng/dynamic-uses@v1 - env: - action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} with: - uses: LocalStack/setup-localstack/preview@${{ env.action-version }} + uses: ${{ env.action-root }}/preview with: |- { "github-token": "${{ inputs.github-token }}", @@ -136,10 +131,9 @@ runs: if: ${{ inputs.state-action == 'start' && inputs.state-backend == 'preview' && (inputs.include-preview == 'true' || inputs.ci-project != '') }} uses: jenseng/dynamic-uses@v1 env: - action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} default-include-preview: ${{ fromJSON('["false","true"]')[github.event_name == 'pull_request'] }} with: - uses: LocalStack/setup-localstack/finish@${{ env.action-version }} + uses: ${{ env.action-root }}/finish with: |- { "github-token": "${{ inputs.github-token }}", @@ -150,10 +144,8 @@ runs: - name: Stop Ephemeral Instance if: ${{ !inputs.skip-preview-stop && inputs.state-action == 'stop' && inputs.state-backend == 'preview' }} uses: jenseng/dynamic-uses@v1 - env: - action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} with: - uses: LocalStack/setup-localstack/ephemeral/shutdown@${{ env.action-version }} + uses: ${{ env.action-root }}/ephemeral/shutdown with: |- { "name": "${{ inputs.github-token }}", diff --git a/startup/action.yml b/startup/action.yml index af3552c..638be45 100644 --- a/startup/action.yml +++ b/startup/action.yml @@ -37,16 +37,13 @@ runs: # with: # github-token: ${{ inputs.github-token }} # ci-project: ${{ inputs.ci-project }} + - run: echo "action-root=$(ls -d ./../../_actions/LocalStack/setup-localstack/*)" >> $GITHUB_ENV + shell: bash - name: Install tools uses: jenseng/dynamic-uses@v1 - env: - action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }} with: - # now we can dynamically determine sub-action versions 🥳 - uses: LocalStack/setup-localstack/tools@${{ env.action-version }} - # the `with` needs to be converted to a valid json string - # keeping in there install-awslocal for backward compatibility + uses: ${{ env.action-root }}/tools with: |- { "install-awslocal": "${{ inputs.install-awslocal }}",