Skip to content

Commit 9f14d63

Browse files
authored
Optimize preview build to avoid checkout on pull_request* events (#633)
1 parent 232421a commit 9f14d63

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

.github/workflows/preview-build.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,24 @@ jobs:
4646
steps:
4747

4848
- name: Checkout
49+
if: contains(fromJSON('["push", "merge_group"]'), github.event_name)
4950
uses: actions/checkout@v4
5051
with:
5152
ref: ${{ github.event.pull_request.head.sha || github.ref }}
5253

5354
- name: Get changed files
54-
if: startsWith(github.event_name, 'pull_request') || github.event_name == 'merge_group'
55+
if: contains(fromJSON('["merge_group", "pull_request", "pull_request_target"]'), github.event_name)
5556
id: check-files
5657
uses: tj-actions/changed-files@d6e91a2266cdb9d62096cebf1e8546899c6aa18f # v45.0.6
5758
with:
5859
files: ${{ inputs.path-pattern != '' && inputs.path-pattern || '**' }}
59-
60+
61+
- name: Checkout
62+
if: startsWith(github.event_name, 'pull_request') && steps.check-files.outputs.any_modified == 'true'
63+
uses: actions/checkout@v4
64+
with:
65+
ref: ${{ github.event.pull_request.head.sha || github.ref }}
66+
6067
- name: Free Disk Space
6168
if: github.repository == 'elastic/asciidocalypse'
6269
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1

0 commit comments

Comments
 (0)