Skip to content

Commit

Permalink
fix: fix sub-action versions
Browse files Browse the repository at this point in the history
  • Loading branch information
lakkeger committed May 16, 2024
1 parent 4e0068a commit f046bca
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 48 deletions.
76 changes: 52 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -43,27 +49,38 @@ 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 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'
Expand All @@ -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 }}
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
action-version: ${{ fromJSON(format('["{0}","{1}"]', github.ref_name, github.head_ref))[github.event_name == 'pull_request'] }}
28 changes: 10 additions & 18 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,14 @@ inputs:
runs:
using: "composite"
steps:
- run: echo "action-root=$(ls -d ./../../_actions/LocalStack/setup-localstack/* | grep -v completed)" >> $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 }}",
Expand All @@ -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: |-
Expand All @@ -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 }}",
Expand All @@ -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 }}",
Expand All @@ -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 }}",
Expand All @@ -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 }}",
Expand Down
9 changes: 3 additions & 6 deletions startup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/* | grep -v completed)" >> $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 }}",
Expand Down

0 comments on commit f046bca

Please sign in to comment.