Skip to content

Commit ca36cdb

Browse files
authored
Fix workflow logic when determining if profiling was triggered on a PR comment (#1306)
1 parent 6905214 commit ca36cdb

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

.github/workflows/run-profiling.yaml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,26 @@ jobs:
3939
profiling-on-sha: ${{ steps.determine-correct-sha.outputs.result }}
4040
profiling-event-trigger: ${{ steps.set-github-info.outputs.event }}
4141
steps:
42+
- id: determine-if-pr-comment
43+
name: Determine if this is a PR comment
44+
run: |
45+
if ! [ -z "${{ github.event.issue.pull_request }}" ]; then echo "is-pr=true" >> "${GITHUB_OUTPUT}"; else echo "is-pr=false" >> "${GITHUB_OUTPUT}"; fi
46+
4247
- id: determine-correct-sha
48+
name: Determine the SHA to run profiling on
4349
uses: actions/github-script@v7
4450
with:
4551
result-encoding: string
4652
script: |
47-
if (!context.payload.issue.pull_request) {
48-
return context.sha;
53+
if ("${{ steps.determine-if-pr-comment.outputs.is-pr }}" === "true") {
54+
const { data: pr } = await github.rest.pulls.get({
55+
owner: context.issue.owner,
56+
repo: context.issue.repo,
57+
pull_number: context.issue.number,
58+
});
59+
return pr.head.sha;
4960
};
50-
const { data: pr } = await github.rest.pulls.get({
51-
owner: context.issue.owner,
52-
repo: context.issue.repo,
53-
pull_number: context.issue.number,
54-
});
55-
return pr.head.sha;
61+
return context.sha;
5662
5763
- id: set-profiling-filename
5864
name: Set profiling output file name

0 commit comments

Comments
 (0)