Skip to content

Commit 63bb304

Browse files
committed
Add conditional trigger for backend workflow
* The build is triggered for a specific service only if its files have been changes
1 parent 7793c74 commit 63bb304

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

.github/workflows/backend.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ on:
44
push:
55
branches: [ 'main' ]
66
paths: [ 'services/match/**', 'services/question/**', 'services/user/**' ]
7-
pull_request:
8-
branches: [ 'main' ]
9-
types: [ 'opened', 'reopened', 'synchronize']
107

118
# Allows you to run this workflow manually from the Actions tab
129
workflow_dispatch:
@@ -41,12 +38,9 @@ jobs:
4138
service:
4239
- '.services/${{ matrix.service }}/**'
4340
44-
- name: Exit if no changes found
45-
if: steps.changes.output.service == 'false'
46-
run: exit 0
47-
4841
- name: Configure AWS credentials
4942
id: aws-configure
43+
if: steps.changes.output.service == 'true'
5044
uses: aws-actions/[email protected]
5145
with:
5246
role-to-assume: ${{ secrets.AWS_BACKEND_ROLE }}
@@ -55,10 +49,12 @@ jobs:
5549

5650
- name: Login to AWS ECR
5751
id: login-ecr
52+
if: steps.changes.output.service == 'true'
5853
uses: aws-actions/[email protected]
5954

60-
- name: Build and push ${{ matrix.service }} image to Amazon ECR
55+
- name: Build and push ${{ matrix.service }} image to AWS ECR
6156
id: build-image
57+
if: steps.changes.output.service == 'true'
6258
env:
6359
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
6460
ECR_REPOSITORY: ${{ matrix.service }}
@@ -70,6 +66,7 @@ jobs:
7066
7167
- name: Update AWS Service (${{ matrix.service }}) # Trigger re-deployment with latest image
7268
id: update-service
69+
if: steps.changes.output.service == 'true'
7370
env:
7471
ECS_SERVICE: ${{ matrix.service }}-service
7572
run: |

0 commit comments

Comments
 (0)