@@ -65,11 +65,11 @@ jobs:
65
65
- name : Not a push event
66
66
id : event-check
67
67
if : contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
68
- # ensure we emit static output to simplify our checks in the build step, next/current output has no barrings during preview builds
68
+ # we always want to run for pull requests, but we do not want to indicate its either content source
69
69
run : |
70
70
echo "content-source-match=true" >> $GITHUB_OUTPUT
71
- echo "content-source-next=true " >> $GITHUB_OUTPUT
72
- echo "content-source-current=true " >> $GITHUB_OUTPUT
71
+ echo "content-source-next=false " >> $GITHUB_OUTPUT
72
+ echo "content-source-current=false " >> $GITHUB_OUTPUT
73
73
- name : Match for push events
74
74
id : match
75
75
if : contains(fromJSON('["push"]'), github.event_name)
@@ -94,31 +94,36 @@ jobs:
94
94
runs-on : ubuntu-latest
95
95
env :
96
96
GITHUB_PR_REF_NAME : ${{ github.event.pull_request.head.ref }}
97
+ MATCH : ${{ needs.match.outputs.content-source-match }}
97
98
needs : [ match ]
98
99
steps :
99
100
100
101
- name : Checkout
101
- if : contains(fromJSON('["push", "merge_group", "workflow_dispatch"]'), github.event_name)
102
+ if : env.MATCH == 'true' && ( contains(fromJSON('["push", "merge_group", "workflow_dispatch"]'), github.event_name) )
102
103
uses : actions/checkout@v4
103
104
with :
104
105
ref : ${{ github.event.pull_request.head.sha || github.ref }}
105
106
106
107
- name : Get changed files
107
- if : contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
108
+ if : env.MATCH == 'true' && ( contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name) )
108
109
id : check-files
109
110
uses : tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
110
111
with :
111
112
files : ${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }}
112
113
113
114
- name : Checkout
114
- if : startsWith(github.event_name, 'pull_request') && steps.check-files.outputs.any_modified == 'true'
115
+ if : env.MATCH == 'true' && ( startsWith(github.event_name, 'pull_request') && steps.check-files.outputs.any_modified == 'true')
115
116
uses : actions/checkout@v4
116
117
with :
117
118
ref : ${{ github.event.pull_request.head.sha || github.ref }}
118
119
persist-credentials : false
119
120
120
121
- name : Create Deployment
121
- if : contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) || (steps.check-files.outputs.any_modified == 'true' && startsWith(github.event_name, 'pull_request'))
122
+ if : |
123
+ env.MATCH == 'true' &&
124
+ (contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
125
+ || (steps.check-files.outputs.any_modified == 'true' && startsWith(github.event_name, 'pull_request'))
126
+ )
122
127
uses : actions/github-script@v7
123
128
id : deployment
124
129
env :
@@ -151,7 +156,7 @@ jobs:
151
156
return deployment.data.id
152
157
153
158
- name : Generate env.PATH_PREFIX
154
- if : steps.deployment.outputs.result
159
+ if : env.MATCH == 'true' && ( steps.deployment.outputs.result)
155
160
env :
156
161
PR_NUMBER : ${{ github.event.pull_request.number }}
157
162
GITHUB_REF_NAME : ${{ github.ref_name }}
@@ -162,10 +167,6 @@ jobs:
162
167
;;
163
168
"push" | "workflow_dispatch")
164
169
echo "PATH_PREFIX=/${GITHUB_REPOSITORY}/tree/${GITHUB_REF_NAME}" >> $GITHUB_ENV
165
- if [[ ! "${GITHUB_REF_NAME}" =~ ^(main|master|16\.x)$ ]]; then
166
- echo "Unsupported ref name: '${GITHUB_REF_NAME}'";
167
- exit 1;
168
- fi
169
170
;;
170
171
*)
171
172
echo "Unsupported event: '${GITHUB_EVENT_NAME}'";
@@ -174,18 +175,22 @@ jobs:
174
175
esac
175
176
176
177
- name : Bootstrap Action Workspace
177
- if : github.repository == 'elastic/docs-builder' && steps.deployment.outputs.result
178
+ if : env.MATCH == 'true' && ( github.repository == 'elastic/docs-builder' && steps.deployment.outputs.result)
178
179
uses : elastic/docs-builder/.github/actions/bootstrap@main
179
180
180
- # we run our artifact directly please use the prebuild
181
+ # we run our artifact directly, please use the prebuild
181
182
# elastic/docs-builder@main GitHub Action for all other repositories!
182
183
- name : Build documentation
183
- if : github.repository == 'elastic/docs-builder' && steps.deployment.outputs.result
184
+ if : env.MATCH == 'true' && ( github.repository == 'elastic/docs-builder' && steps.deployment.outputs.result)
184
185
run : |
185
186
dotnet run --project src/tooling/docs-builder -- --strict --path-prefix "${PATH_PREFIX}"
186
187
187
188
- name : Build documentation
188
- if : github.repository != 'elastic/docs-builder' && (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group'))
189
+ if : |
190
+ env.MATCH == 'true' &&
191
+ (github.repository != 'elastic/docs-builder' &&
192
+ (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group'))
193
+ )
189
194
uses : elastic/docs-builder@main
190
195
id : docs-build
191
196
continue-on-error : ${{ fromJSON(inputs.continue-on-error != '' && inputs.continue-on-error || 'false') }}
@@ -195,32 +200,46 @@ jobs:
195
200
metadata-only : ${{ fromJSON(inputs.metadata-only != '' && inputs.metadata-only || 'true') }}
196
201
197
202
- name : ' Validate inbound links'
198
- if : ${{ !cancelled() && steps.docs-build.outputs.skip != 'true' && (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group')) }}
203
+ if : |
204
+ env.MATCH == 'true' &&
205
+ (!cancelled() && steps.docs-build.outputs.skip != 'true'
206
+ && (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group'))
207
+ )
199
208
uses : elastic/docs-builder/actions/validate-inbound-local@main
200
209
201
210
- name : ' Validate local path prefixes against those claimed by global navigation.yml'
202
- if : ${{ !cancelled() && steps.docs-build.outputs.skip != 'true' && (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group')) }}
211
+ if : |
212
+ env.MATCH == 'true' &&
213
+ (!cancelled() && steps.docs-build.outputs.skip != 'true' &&
214
+ (steps.deployment.outputs.result || (steps.check-files.outputs.any_modified == 'true' && github.event_name == 'merge_group'))
215
+ )
203
216
uses : elastic/docs-builder/actions/validate-path-prefixes-local@main
204
217
205
218
- uses : elastic/docs-builder/.github/actions/aws-auth@main
206
219
if : ${{ !cancelled() && steps.docs-build.outputs.skip != 'true' && steps.deployment.outputs.result }}
207
220
208
221
- name : Upload to S3
209
222
id : s3-upload
210
- if : ${{ !cancelled() && steps.docs-build.outputs.skip != 'true' && steps.deployment.outputs.result }}
223
+ if : |
224
+ env.MATCH == 'true' &&
225
+ (!cancelled() && steps.docs-build.outputs.skip != 'true' && steps.deployment.outputs.result)
211
226
run : |
212
227
aws s3 sync .artifacts/docs/html "s3://elastic-docs-v3-website-preview${PATH_PREFIX}" --delete --no-follow-symlinks
213
228
aws cloudfront create-invalidation \
214
229
--distribution-id EKT7LT5PM8RKS \
215
230
--paths "${PATH_PREFIX}" "${PATH_PREFIX}/*"
216
231
217
232
- name : Update Link Index
218
- if : contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name) && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && steps.s3-upload.outcome == 'success'
233
+ if : |
234
+ env.MATCH == 'true' &&
235
+ (contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
236
+ && (needs.match.outputs.content-source-current == 'true' || needs.match.outputs.content-source-next == 'true')
237
+ && steps.s3-upload.outcome == 'success')
219
238
uses : elastic/docs-builder/actions/update-link-index@main
220
239
221
240
- name : Update deployment status
222
241
uses : actions/github-script@v7
223
- if : always() && steps.deployment.outputs.result
242
+ if : env.MATCH == 'true' && ( always() && steps.deployment.outputs.result)
224
243
env :
225
244
PR_NUMBER : ${{ github.event.pull_request.number }}
226
245
LANDING_PAGE_PATH : ${{ steps.docs-build.outputs.landing-page-path || env.PATH_PREFIX }}
0 commit comments