Skip to content

Commit

Permalink
Build dynamic matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-wal committed Sep 2, 2024
1 parent e22838d commit 231de67
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/deploy-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,26 @@ on:
default: 'latest'

jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.prepare-matrix.outputs.matrix }}
steps:
- name: Determine matrix
id: set-matrix
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "matrix=$(jq -cr '@json' <<< "['staging']")" >> $GITHUB_OUTPUT
else
echo "matrix=$(jq -cr '@json' <<< "['production', 'staging']")" >> $GITHUB_OUTPUT
fi
ReuseableMatrixJobForDeployment:
needs: 'prepare-matrix'
strategy:
matrix:
build-type: [production, staging]
build-type: ${{ fromJSON(needs.prepare-matrix.outputs.matrix) }}

include:
- build-type: production
tag_suffix: prod
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/release-new-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,9 @@ jobs:
with:
flavor: |
latest=false
suffix=-${{ inputs.tag_suffix }}
images: public.ecr.aws/f4h6r4m9/${{ env.ECR_REPOSITORY }}
tags: |
type=semver,pattern={{version}},value=v${{ inputs.version }},enable=${{inputs.version != ''}}
type=raw,value={{branch}},enable=${{inputs.version != ''}}
type=semver,pattern={{branch}}-{{version}},value=v${{ inputs.version }},enable=${{inputs.version != ''}}
type=ref,event=pr,pattern={{branch}}
- name: Build tag
Expand Down

0 comments on commit 231de67

Please sign in to comment.