@@ -60,29 +60,47 @@ jobs:
6060 check :
6161 if : github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks)
6262 runs-on : ubuntu-latest
63+ outputs :
64+ any_modified : ${{ steps.check-files.outputs.any_modified }}
6365 env :
6466 AUTHOR_ASSOCIATION : ${{ github.event.pull_request.author_association }}
6567 steps :
68+ - name : Checkout
69+ if : contains(fromJSON('["push", "merge_group", "workflow_dispatch"]'), github.event_name)
70+ uses : actions/checkout@v4
71+ with :
72+ ref : ${{ github.event.pull_request.head.sha || github.ref }}
73+ - name : Get changed files
74+ if : contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
75+ id : check-files
76+ uses : tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
77+ with :
78+ files : ${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }}
6679 - name : Check PR author association
80+ env :
81+ ANY_MODIFIED : $ {{ steps.check-files.outputs.any_modified }}
82+ # language=bash
6783 run : |
6884 case "${GITHUB_EVENT_NAME}" in
6985 "pull_request" | "pull_request_target")
70- if [[ "${AUTHOR_ASSOCIATION}" == "MEMBER" ]]; then
86+ # If no documentation files changed, we can just continue.
87+ # The build job is handling the logic to skip the build.
88+ if [[ "${ANY_MODIFIED}" == "false" || "${AUTHOR_ASSOCIATION}" == "MEMBER" ]]; then
7189 exit 0;
7290 else
7391 echo "::error::You must be a member of the elastic organization to trigger a preview build. Please ask a member of the elastic organization to review your PR and re-trigger the build.";
7492 exit 1;
7593 fi
7694 ;;
77- "push" | "workflow_dispatch")
95+ "push" | "workflow_dispatch" | "merge_group" )
7896 exit 0;
7997 ;;
8098 *)
8199 echo "Unsupported event: '${GITHUB_EVENT_NAME}'";
82100 exit 1;
83101 ;;
84102 esac
85-
103+
86104 match :
87105 if : github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks)
88106 needs : check
@@ -125,24 +143,13 @@ jobs:
125143 env :
126144 GITHUB_PR_REF_NAME : ${{ github.event.pull_request.head.ref }}
127145 MATCH : ${{ needs.match.outputs.content-source-match }}
128- needs : [ match ]
146+ needs :
147+ - check
148+ - match
129149 steps :
130150
131151 - name : Checkout
132- if : env.MATCH == 'true' && (contains(fromJSON('["push", "merge_group", "workflow_dispatch"]'), github.event_name))
133- uses : actions/checkout@v4
134- with :
135- ref : ${{ github.event.pull_request.head.sha || github.ref }}
136-
137- - name : Get changed files
138- if : env.MATCH == 'true' && (contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name))
139- id : check-files
140- uses : tj-actions/changed-files@2f7c5bfce28377bc069a65ba478de0a74aa0ca32 # v46.0.1
141- with :
142- files : ${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }}
143-
144- - name : Checkout
145- if : env.MATCH == 'true' && (startsWith(github.event_name, 'pull_request') && steps.check-files.outputs.any_modified == 'true')
152+ if : env.MATCH == 'true' && (startsWith(github.event_name, 'pull_request') && needs.check.outputs.any_modified == 'true')
146153 uses : actions/checkout@v4
147154 with :
148155 ref : ${{ github.event.pull_request.head.sha || github.ref }}
@@ -152,7 +159,7 @@ jobs:
152159 if : |
153160 env.MATCH == 'true' &&
154161 (contains(fromJSON('["push", "workflow_dispatch"]'), github.event_name)
155- || (steps .check-files .outputs.any_modified == 'true' && startsWith(github.event_name, 'pull_request'))
162+ || (needs .check.outputs.any_modified == 'true' && startsWith(github.event_name, 'pull_request'))
156163 )
157164 uses : actions/github-script@v7
158165 id : deployment
@@ -161,6 +168,7 @@ jobs:
161168 REF : ${{ startsWith(github.event_name, 'pull_request') && github.event.pull_request.head.sha || github.ref_name }}
162169 with :
163170 result-encoding : string
171+ # language=javascript
164172 script : |
165173 const { owner, repo } = context.repo;
166174 const prNumber = process.env.PR_NUMBER;
@@ -219,7 +227,7 @@ jobs:
219227 if : |
220228 env.MATCH == 'true' &&
221229 (github.repository != 'elastic/docs-builder' &&
222- (steps.deployment.outputs.result || (steps .check-files .outputs.any_modified == 'true' && github.event_name == 'merge_group'))
230+ (steps.deployment.outputs.result || (needs .check.outputs.any_modified == 'true' && github.event_name == 'merge_group'))
223231 )
224232 uses : elastic/docs-builder@main
225233 id : docs-build
@@ -233,15 +241,15 @@ jobs:
233241 if : |
234242 env.MATCH == 'true' &&
235243 (!cancelled() && steps.docs-build.outputs.skip != 'true'
236- && (steps.deployment.outputs.result || (steps .check-files .outputs.any_modified == 'true' && github.event_name == 'merge_group'))
244+ && (steps.deployment.outputs.result || (needs .check.outputs.any_modified == 'true' && github.event_name == 'merge_group'))
237245 )
238246 uses : elastic/docs-builder/actions/validate-inbound-local@main
239247
240248 - name : ' Validate local path prefixes against those claimed by global navigation.yml'
241249 if : |
242250 env.MATCH == 'true' &&
243251 (!cancelled() && steps.docs-build.outputs.skip != 'true' &&
244- (steps.deployment.outputs.result || (steps .check-files .outputs.any_modified == 'true' && github.event_name == 'merge_group'))
252+ (steps.deployment.outputs.result || (needs .check.outputs.any_modified == 'true' && github.event_name == 'merge_group'))
245253 )
246254 uses : elastic/docs-builder/actions/validate-path-prefixes-local@main
247255
@@ -278,6 +286,7 @@ jobs:
278286 PR_NUMBER : ${{ github.event.pull_request.number }}
279287 LANDING_PAGE_PATH : ${{ steps.docs-build.outputs.landing-page-path || env.PATH_PREFIX }}
280288 with :
289+ # language=jinja
281290 script : |
282291 await github.rest.repos.createDeploymentStatus({
283292 owner: context.repo.owner,
0 commit comments