Skip to content

Commit eb9fa41

Browse files
committed
Fix file list for non pull request events
We still support push events for some projects but file list has been broken for a while because pull_request does not exist on the event context so node aborts. Instead use the actions || condition that handles all failures of the first condition. CHange-type: patch Signed-off-by: Kyle Harding <[email protected]>
1 parent 49ce6d5 commit eb9fa41

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

Diff for: .github/workflows/flowzone.yml

+5-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: flowzone.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -1863,16 +1863,18 @@ jobs:
18631863
- name: List files in project root
18641864
id: project-root
18651865
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
1866+
env:
1867+
# Use the tip of the pull request branch for pull request (target) events.
1868+
# Use the event sha for other events.
1869+
REF: ${{ github.event.pull_request.head.sha || github.sha }}
18661870
with:
18671871
github-token: ${{ github.token }}
18681872
result-encoding: json
1869-
# Use the tip of the pull request branch for pull request (target) events.
1870-
# Use the event sha for other events.
18711873
script: |
18721874
const { data } = await github.rest.repos.getContent({
18731875
owner: context.repo.owner,
18741876
repo: context.repo.repo,
1875-
ref: context.payload.pull_request.head.sha || context.ref
1877+
ref: process.env.REF
18761878
});
18771879
18781880
return data
@@ -1887,18 +1889,19 @@ jobs:
18871889
if: inputs.working_directory && inputs.working_directory != '.'
18881890
env:
18891891
WORKING_DIRECTORY: ${{ inputs.working_directory }}
1892+
# Use the tip of the pull request branch for pull request (target) events.
1893+
# Use the event sha for other events.
1894+
REF: ${{ github.event.pull_request.head.sha || github.sha }}
18901895
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
18911896
with:
18921897
github-token: ${{ github.token }}
18931898
result-encoding: json
1894-
# Use the tip of the pull request branch for pull request (target) events.
1895-
# Use the event sha for other events.
18961899
# Remove preceeding ./ from the working directory if it exists.
18971900
script: |
18981901
const { data } = await github.rest.repos.getContent({
18991902
owner: context.repo.owner,
19001903
repo: context.repo.repo,
1901-
ref: context.payload.pull_request.head.sha || context.ref,
1904+
ref: process.env.REF,
19021905
path: process.env.WORKING_DIRECTORY.startsWith('./') ? process.env.WORKING_DIRECTORY.slice(2) : process.env.WORKING_DIRECTORY
19031906
});
19041907

0 commit comments

Comments
 (0)