23
23
type : string
24
24
build_type :
25
25
type : string
26
+ use_merge_sha :
27
+ type : boolean
28
+ default : false
29
+ skip_tests :
30
+ type : boolean
31
+ default : false
32
+ description : if this option is true, we would skip tests while building docker image
33
+ workflow_url :
34
+ type : string
26
35
secrets :
27
36
DOCKERHUB_PROD_TOKEN :
28
37
required : true
31
40
DOCKERHUB_USERNAME : rudderlabs
32
41
33
42
jobs :
43
+ get_sha :
44
+ runs-on : ubuntu-latest
45
+ name : Get SHA information
46
+ outputs :
47
+ sha : ${{steps.getSHA.outputs.SHA}}
48
+ steps :
49
+ - name : Checkout SHA
50
+ id : getSHA
51
+ run : |
52
+ if ${{inputs.use_merge_sha}} == true; then
53
+ sha=$(echo ${{github.sha}})
54
+ else
55
+ sha=$(echo ${{ github.event.pull_request.head.sha }})
56
+ fi
57
+ echo "SHA: $sha"
58
+ echo "SHA=$sha" >> $GITHUB_OUTPUT
59
+
60
+ get_changed_files :
61
+ runs-on : ubuntu-latest
62
+ name : Get Changed files
63
+ outputs :
64
+ should_execute_tests : ${{ steps.processing.outputs.should_execute_tests }}
65
+ steps :
66
+ - name : Checkout
67
+
68
+ with :
69
+ fetch-depth : 1
70
+ - id : files
71
+
72
+ with :
73
+ token : ${{ secrets.GITHUB_TOKEN }}
74
+ format : ' json'
75
+ - id : processing
76
+ run : |
77
+ readarray -t modified_files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.modified }}')"
78
+ echo "Modified files: $modified_files"
79
+ found=false
80
+ for modified_file in "${modified_files[@]}"; do
81
+ if [[ "$modified_file" == "Dockerfile" || "$modified_file" == "docker-compose.yml" || "$modified_file" == "Dockerfile" || "$modified_file" == "Dockerfile-ut-func" ]]; then
82
+ found=true
83
+ break
84
+ fi
85
+ done
86
+ echo "Match Found: $found"
87
+ echo "::set-output name=should_execute_tests::$found"
88
+
34
89
build-transformer-image-arm64 :
35
90
name : Build Transformer Docker Image ARM64
36
91
runs-on : [self-hosted, Linux, ARM64]
92
+ needs : [get_sha, get_changed_files]
37
93
steps :
38
94
- name : Checkout
39
95
40
96
with :
41
- ref : ${{ github.event.pull_request.head .sha }}
97
+ ref : ${{ needs.get_sha.outputs .sha }}
42
98
fetch-depth : 1
43
99
44
100
- name : Setup Docker Buildx
45
- uses : docker/setup-buildx-action@v3.0.0
101
+ uses : docker/setup-buildx-action@v3.6.1
46
102
47
103
- name : Login to DockerHub
48
- uses : docker/login-action@v2.1 .0
104
+ uses : docker/login-action@v3.3 .0
49
105
with :
50
106
username : ${{ env.DOCKERHUB_USERNAME }}
51
107
password : ${{ secrets.DOCKERHUB_PROD_TOKEN }}
52
108
53
109
- name : Build Docker Image
54
- uses : docker/build-push-action@v5.1 .0
110
+ uses : docker/build-push-action@v6.7 .0
55
111
with :
56
112
context : .
57
113
file : ${{ inputs.dockerfile }}
@@ -62,12 +118,13 @@ jobs:
62
118
# cache-to: type=gha,mode=max
63
119
64
120
- name : Run Tests
121
+ if : ${{ inputs.skip_tests != true || needs.get_changed_files.outputs.should_execute_tests == true }}
65
122
run : |
66
123
docker run ${{ inputs.build_tag }} npm run test:js:ci
67
124
docker run ${{ inputs.build_tag }} npm run test:ts:ci
68
125
69
126
- name : Build and Push Multi-platform Images
70
- uses : docker/build-push-action@v5.1 .0
127
+ uses : docker/build-push-action@v6.7 .0
71
128
with :
72
129
context : .
73
130
file : ${{ inputs.dockerfile }}
@@ -85,24 +142,25 @@ jobs:
85
142
build-transformer-image-amd64 :
86
143
name : Build Transformer Docker Image AMD64
87
144
runs-on : [self-hosted, Linux, X64]
145
+ needs : [get_sha, get_changed_files]
88
146
steps :
89
147
- name : Checkout
90
148
91
149
with :
92
- ref : ${{ github.event.pull_request.head .sha }}
150
+ ref : ${{ needs.get_sha.outputs .sha }}
93
151
fetch-depth : 1
94
152
95
153
- name : Setup Docker Buildx
96
- uses : docker/setup-buildx-action@v3.0.0
154
+ uses : docker/setup-buildx-action@v3.6.1
97
155
98
156
- name : Login to DockerHub
99
- uses : docker/login-action@v2.1 .0
157
+ uses : docker/login-action@v3.3 .0
100
158
with :
101
159
username : ${{ env.DOCKERHUB_USERNAME }}
102
160
password : ${{ secrets.DOCKERHUB_PROD_TOKEN }}
103
161
104
162
- name : Build Docker Image
105
- uses : docker/build-push-action@v5.1 .0
163
+ uses : docker/build-push-action@v6.7 .0
106
164
with :
107
165
context : .
108
166
file : ${{ inputs.dockerfile }}
@@ -113,12 +171,13 @@ jobs:
113
171
# cache-to: type=gha,mode=max
114
172
115
173
- name : Run Tests
174
+ if : ${{ inputs.skip_tests != true || needs.get_changed_files.outputs.should_execute_tests == true }}
116
175
run : |
117
176
docker run ${{ inputs.build_tag }} npm run test:js:ci
118
177
docker run ${{ inputs.build_tag }} npm run test:ts:ci
119
178
120
179
- name : Build and Push Multi-platform Images
121
- uses : docker/build-push-action@v5.1 .0
180
+ uses : docker/build-push-action@v6.7 .0
122
181
with :
123
182
context : .
124
183
file : ${{ inputs.dockerfile }}
@@ -140,10 +199,10 @@ jobs:
140
199
141
200
steps :
142
201
- name : Set up Docker Buildx
143
- uses : docker/setup-buildx-action@v3.0.0
202
+ uses : docker/setup-buildx-action@v3.6.1
144
203
145
204
- name : Login to DockerHub
146
- uses : docker/login-action@v2.1 .0
205
+ uses : docker/login-action@v3.3 .0
147
206
with :
148
207
username : ${{ env.DOCKERHUB_USERNAME }}
149
208
password : ${{ secrets.DOCKERHUB_PROD_TOKEN }}
0 commit comments