Skip to content

Commit 632d1c4

Browse files
pgettabilalesi
authored andcommitted
Consolidate push and deploy actions for staging ci (#86)
* Consolidate image publishing and re-deploying in staging * Only allow building production images from main branch * Add list of commits to the tag message * Disable staging deployment for the current branch * Debug extracting git commits * Remove tag messages for now
1 parent 43520f1 commit 632d1c4

File tree

3 files changed

+28
-38
lines changed

3 files changed

+28
-38
lines changed

.github/workflows/publish-production-image.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ jobs:
1313
ENVIRONMENT: staging
1414
IMAGE_NAME: ${{ vars.PUBLICECR_URI }}
1515
steps:
16+
- name: Fail if branch is not main
17+
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main'
18+
run: |
19+
echo "This workflow should not be triggered with workflow_dispatch on a branch other than main"
20+
exit 1
21+
1622
- name: Checkout repository
1723
uses: actions/checkout@v4
1824
with:

.github/workflows/publish-staging-image.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish STAGING image
1+
name: Deploy to STAGING
22

33
on:
44
push:
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88

99
jobs:
10-
publish-image:
10+
deploy-staging:
1111
runs-on: ubuntu-latest
1212
env:
1313
ENVIRONMENT: staging
@@ -23,7 +23,7 @@ jobs:
2323
aws-secret-access-key: ${{ secrets.PUBLICECR_UPLOAD_SECRET_ACCESS_KEY }}
2424
aws-region: ${{ vars.PUBLICECR_REGION }}
2525

26-
- name: Authenticate with AWS Public ECR
26+
- name: Authenticate with AWS ECR
2727
uses: aws-actions/amazon-ecr-login@v2
2828
with:
2929
registry-type: public
@@ -35,3 +35,22 @@ jobs:
3535
- name: Publish To AWS ECR
3636
run: |
3737
docker push ${{ vars.PUBLICECR_URI }}:staging
38+
39+
- name: Authenticate with AWS ECS
40+
uses: aws-actions/configure-aws-credentials@v4
41+
with:
42+
role-to-assume: ${{ vars.AWS_STAGING_ECS_REDEPLOY_ROLE_ARN }}
43+
aws-region: ${{ vars.AWS_STAGING_REGION }}
44+
45+
- name: Trigger new deployment
46+
run: |
47+
aws ecs update-service \
48+
--cluster ${{ vars.AWS_STAGING_ECS_CLUSTER }} \
49+
--service ${{ vars.AWS_STAGING_ECS_SERVICE }} \
50+
--force-new-deployment
51+
52+
- name: Wait until the service is stable
53+
run: |
54+
aws ecs wait services-stable \
55+
--cluster ${{ vars.AWS_STAGING_ECS_CLUSTER }} \
56+
--service ${{ vars.AWS_STAGING_ECS_SERVICE }}

.github/workflows/staging-redeploy.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)