Skip to content

Commit 4a7909a

Browse files
committed
Build production image only from main or release branch
1 parent 3707805 commit 4a7909a

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

.github/workflows/build-and-push-image.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
echo "BUILD_NEEDED=true" >> $GITHUB_ENV
3535
fi
3636
- name: Configure AWS Production credentials
37+
if: ${{ github.ref_name == 'main' || github.ref_name == 'release' }}
3738
uses: aws-actions/configure-aws-credentials@v4
3839
with:
3940
role-to-assume: arn:aws:iam::820242920762:role/GithubDeployMavisAndInfrastructure
@@ -64,16 +65,29 @@ jobs:
6465
with:
6566
name: image
6667
path: image.tar
68+
define-matrix:
69+
name: Determine AWS roles to push the image
70+
runs-on: ubuntu-latest
71+
needs: check-image-presence
72+
outputs:
73+
aws-roles: ${{ steps.determine-aws-roles.outputs.aws-roles }}
74+
steps:
75+
- name: Set aws roles
76+
id: determine-aws-roles
77+
run: |
78+
if [ ${{ github.ref_name }} = 'main' ] || [ ${{ github.ref_name }} = 'release' ]; then
79+
echo 'aws-roles=["arn:aws:iam::393416225559:role/GithubDeployMavisAndInfrastructure", "arn:aws:iam::820242920762:role/GithubDeployMavisAndInfrastructure"]' >> $GITHUB_OUTPUT
80+
else
81+
echo 'aws-roles=["arn:aws:iam::393416225559:role/GithubDeployMavisAndInfrastructure"]' >> $GITHUB_OUTPUT
82+
fi
6783
push:
6884
runs-on: ubuntu-latest
69-
needs: build
85+
needs: [build, define-matrix]
7086
permissions:
7187
id-token: write
7288
strategy:
7389
matrix:
74-
aws-role:
75-
- arn:aws:iam::820242920762:role/GithubDeployMavisAndInfrastructure
76-
- arn:aws:iam::393416225559:role/GithubDeployMavisAndInfrastructure
90+
aws-role: ${{ fromJSON(needs.determine-aws-roles.outputs.aws-roles) }}
7791
steps:
7892
- name: Download Docker image
7993
uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)