Skip to content

Commit

Permalink
feat: tweak logic for preview ci
Browse files Browse the repository at this point in the history
  • Loading branch information
lakkeger committed May 16, 2024
1 parent da81a10 commit 4e0068a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/ephemeral.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@ jobs:
- uses: actions/checkout@v3

- name: Deploy Preview
uses: ./preview
uses: ./
with:
localstack-api-key: ${{ secrets.LOCALSTACK_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
state-backend: preview
state-action: start
skip-preview-stop: 'true'
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}

# We want explicit shutdown
- name: Shutdown ephemeral instance
uses: ./ephemeral/shutdown
uses: ./
with:
localstack-api-key: ${{ secrets.LOCALSTACK_API_KEY }}
github-token: ${{ secrets.GITHUB_TOKEN }}
state-backend: preview
state-action: stop
env:
LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }}
10 changes: 5 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ runs:
steps:
- name: Install tools
uses: jenseng/dynamic-uses@v1
if: ${{ inputs.skip-startup == 'true' }}
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:
Expand All @@ -86,7 +86,7 @@ runs:
- name: Start Localstack
uses: jenseng/dynamic-uses@v1
if: ${{ inputs.skip-startup != 'true' }}
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:
Expand Down Expand Up @@ -133,7 +133,7 @@ runs:
}
- name: Display Ephemeral Instance URL
if: ${{ inputs.state-action == 'start' && inputs.state-backend == 'preview' }}
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'] }}
Expand All @@ -144,11 +144,11 @@ runs:
{
"github-token": "${{ inputs.github-token }}",
"ci-project": "${{ inputs.ci-project }}",
"include-preview": "${{ fromJSON('["{0}","{1}"]', env.include-preview, inputs.include-preview))[inputs.include-preview != ''] }}"
"include-preview": "${{ fromJSON(format('["{0}","{1}"]', env.include-preview, inputs.include-preview))[inputs.include-preview != ''] }}"
}
- name: Stop Ephemeral Instance
if: ${{ !inputs.skip-preview-stop && (inputs.state-action == 'stop' && inputs.state-backend == 'preview' }}
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'] }}
Expand Down

0 comments on commit 4e0068a

Please sign in to comment.