46
46
CODER_BASE_IMAGE_TAG : ${{ steps.set_tags.outputs.CODER_BASE_IMAGE_TAG }}
47
47
CODER_IMAGE_TAG : ${{ steps.set_tags.outputs.CODER_IMAGE_TAG }}
48
48
NEW : ${{ steps.check_deployment.outputs.new }}
49
- BUILD : ${{ steps.filter.outputs.all_count > steps.filter.outputs.ignored_count }}
49
+ BUILD : ${{ steps.filter.outputs.all_count > steps.filter.outputs.ignored_count || steps.check_deployment.outputs.new }}
50
50
51
51
runs-on : " ubuntu-latest"
52
52
steps :
@@ -87,13 +87,14 @@ jobs:
87
87
echo "Deployment already exists. Skipping deployment."
88
88
new=false
89
89
else
90
- echo "Deployment doesn't exist. Creating a new one. "
90
+ echo "Deployment doesn't exist."
91
91
new=true
92
92
fi
93
93
echo "new=$new" >> $GITHUB_OUTPUT
94
94
95
95
- name : Find Comment
96
96
uses : peter-evans/find-comment@v2
97
+ if : github.event_name == 'workflow_dispatch' || steps.check_deployment.outputs.NEW == 'false'
97
98
id : fc
98
99
with :
99
100
issue-number : ${{ steps.pr_info.outputs.PR_NUMBER }}
@@ -103,6 +104,7 @@ jobs:
103
104
104
105
- name : Comment on PR
105
106
id : comment_id
107
+ if : github.event_name == 'workflow_dispatch' || steps.check_deployment.outputs.NEW == 'false'
106
108
uses : peter-evans/create-or-update-comment@v3
107
109
with :
108
110
comment-id : ${{ steps.fc.outputs.comment-id }}
@@ -116,12 +118,14 @@ jobs:
116
118
reactions-edit-mode : replace
117
119
118
120
- name : Checkout
121
+ if : github.event_name == 'workflow_dispatch' || steps.check_deployment.outputs.NEW == 'false'
119
122
uses : actions/checkout@v3
120
123
with :
121
124
ref : ${{ steps.pr_info.outputs.PR_BRANCH }}
122
125
fetch-depth : 0
123
126
124
127
- name : Check changed files
128
+ if : github.event_name == 'workflow_dispatch' || steps.check_deployment.outputs.NEW == 'false'
125
129
uses : dorny/paths-filter@v2
126
130
id : filter
127
131
with :
@@ -145,6 +149,7 @@ jobs:
145
149
- "scripts/**/*[^D][^o][^c][^k][^e][^r][^f][^i][^l][^e][.][b][^a][^s][^e]*"
146
150
147
151
- name : Print number of changed files
152
+ if : github.event_name == 'workflow_dispatch' || steps.check_deployment.outputs.NEW == 'false'
148
153
run : |
149
154
set -euxo pipefail
150
155
echo "Total number of changed files: ${{ steps.filter.outputs.all_count }}"
@@ -154,10 +159,10 @@ jobs:
154
159
needs : get_info
155
160
# Skips the build job if the workflow was triggered by a workflow_dispatch event and the skip_build input is set to true
156
161
# or if the workflow was triggered by an issue_comment event and the comment body contains --skip-build
157
- # alwyas run the build job if the workflow was triggered by a pull_request event
162
+ # always run the build job if a pull_request event triggered the workflow
158
163
if : |
159
164
(github.event_name == 'workflow_dispatch' && github.event.inputs.skip_build == 'false') ||
160
- (github.event_name == 'pull_request' && needs.get_info.outputs.NEW == 'false')
165
+ (github.event_name == 'pull_request' && needs.get_info.result == 'success' && needs.get_info. outputs.NEW == 'false')
161
166
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
162
167
env :
163
168
DOCKER_CLI_EXPERIMENTAL : " enabled"
@@ -211,7 +216,9 @@ jobs:
211
216
deploy :
212
217
needs : [build, get_info]
213
218
# Run deploy job only if build job was successful or skipped
214
- if : always() && (needs.build.result == 'success' || needs.build.result == 'skipped') && needs.get_info.result == 'success'
219
+ if : |
220
+ always() && (needs.build.result == 'success' || needs.build.result == 'skipped') &&
221
+ (github.event_name == 'workflow_dispatch' || needs.get_info.outputs.NEW == 'false')
215
222
runs-on : " ubuntu-latest"
216
223
env :
217
224
CODER_IMAGE_TAG : ${{ needs.get_info.outputs.CODER_IMAGE_TAG }}
@@ -287,6 +294,11 @@ jobs:
287
294
echo "Certificate exists. Skipping certificate creation."
288
295
fi
289
296
echo "Copy certificate from pr-deployment-certs to pr${{ env.PR_NUMBER }} namespace"
297
+ until kubectl get secret pr${{ env.PR_NUMBER }}-tls -n pr-deployment-certs &> /dev/null
298
+ do
299
+ echo "Waiting for secret pr${{ env.PR_NUMBER }}-tls to be created..."
300
+ sleep 5
301
+ done
290
302
(
291
303
kubectl get secret pr${{ env.PR_NUMBER }}-tls -n pr-deployment-certs -o json |
292
304
jq 'del(.metadata.namespace,.metadata.creationTimestamp,.metadata.resourceVersion,.metadata.selfLink,.metadata.uid,.metadata.managedFields)' |
0 commit comments