@@ -27,47 +27,12 @@ permissions:
27
27
contents : read
28
28
pull-requests : read
29
29
jobs :
30
- detect-changes :
31
- # only run this job when a PR is merged or manually triggered
32
- # if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
33
- name : Detect Changes
34
- runs-on : ubuntu-latest
35
- env :
36
- # select environment based on branch or manual input
37
- ENVIRONMENT : ${{ inputs.environment || (github.ref == 'refs/heads/main' && 'staging') }}
38
- outputs :
39
- frontend_changed : ${{ steps.filter.outputs.frontend }}
40
- backend_changed : ${{ steps.filter.outputs.backend }}
41
- environment : ${{ env.ENVIRONMENT }}
42
- steps :
43
- - uses : actions/checkout@v4
44
- with :
45
- persist-credentials : false
46
- - name : Check changed files
47
- id : filter
48
- uses : dorny/paths-filter@v3
49
- with :
50
- filters : |
51
- frontend:
52
- - 'frontend/**'
53
- backend:
54
- - 'backend/**'
55
- - name : Export change detection outputs # Safely export outputs to env variables
56
- env :
57
- FRONTEND_CHANGED_OUTPUT : ${{ steps.filter.outputs.frontend }}
58
- BACKEND_CHANGED_OUTPUT : ${{ steps.filter.outputs.backend }}
59
- run : |
60
- # Safely write environment variables using printf to avoid template injection
61
- printf "FRONTEND_CHANGED=%q\n" "$FRONTEND_CHANGED_OUTPUT" >> "$GITHUB_ENV"
62
- printf "BACKEND_CHANGED=%q\n" "$BACKEND_CHANGED_OUTPUT" >> "$GITHUB_ENV"
63
-
64
30
build-and-push :
65
31
permissions :
66
32
id-token : write
67
33
name : Build and Push Docker Images
68
34
runs-on : ubuntu-latest
69
- needs : detect-changes
70
- environment : ${{ needs.detect-changes.outputs.environment }}
35
+ environment : ${{ inputs.environment || (github.ref == 'refs/heads/main' && 'staging') }}
71
36
strategy :
72
37
matrix :
73
38
service : [frontend, backend]
89
54
mask-password : " true"
90
55
- name : Build and push Docker image
91
56
id : build-and-push
92
- if : |
93
- (matrix.service == 'frontend' && needs.detect-changes.outputs.frontend_changed == 'true') ||
94
- (matrix.service == 'backend' && needs.detect-changes.outputs.backend_changed == 'true')
95
57
env :
96
58
ECR_REGISTRY : ${{ steps.login-ecr.outputs.registry }}
97
59
ECR_REPOSITORY_PREFIX : ${{ vars.ECR_REPOSITORY_PREFIX }}
108
70
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
109
71
update-helm-values :
110
72
name : Update Helm Values
111
- needs : [build-and-push, detect-changes ]
73
+ needs : [build-and-push]
112
74
runs-on : ubuntu-latest
113
- environment : ${{ needs.detect-changes.outputs. environment }}
75
+ environment : ${{ inputs. environment || (github.ref == 'refs/heads/main' && 'staging') }}
114
76
steps :
115
77
- name : Set up SSH for private repo access
116
78
uses :
webfactory/[email protected]
@@ -142,18 +104,13 @@ jobs:
142
104
143
105
VALUES_FILE="deployments/clusters/$CLUSTER_NAME/values/strata-apps-values.yaml"
144
106
145
- # Added boolean validation function
146
- validate_boolean() { [[ "$1" == "true" || "$1" == "false" ]]; }
147
107
148
- if [[ "$FRONTEND_CHANGED" == "true" ]]; then
149
- echo "Updating frontend tag in $VALUES_FILE"
150
- yq eval -i ".strataDashboard.frontend.image.tag = \"$SHORT_TAG\"" "$VALUES_FILE"
151
- fi
108
+ echo "Updating frontend tag in $VALUES_FILE"
109
+ yq eval -i ".strataDashboard.frontend.image.tag = \"$SHORT_TAG\"" "$VALUES_FILE"
110
+
111
+ echo "Updating backend tag in $VALUES_FILE"
112
+ yq eval -i ".strataDashboard.backend.image.tag = \"$SHORT_TAG\"" "$VALUES_FILE"
152
113
153
- if [[ "$BACKEND_CHANGED" == "true" ]]; then
154
- echo "Updating backend tag in $VALUES_FILE"
155
- yq eval -i ".strataDashboard.backend.image.tag = \"$SHORT_TAG\"" "$VALUES_FILE"
156
- fi
157
114
158
115
- name : Commit and push changes
159
116
env :
0 commit comments