Skip to content

Commit 422e864

Browse files
authored
chore(ci): get pr number and sha from github context (#35405)
### Issue # (if applicable) Related to #35268 as the previous fix didn't fully work ### Reason for this change The Pr linter workflow does not reach the code of the linter itself because it stop on error when being triggered at the end of a build, see the [following run](https://github.com/aws/aws-cdk/actions/runs/17435099055/job/49502649374) for example. ### Description of changes Continue if `'Download workflow_run artifact'` to get the PR number and the pr sha from the Github context. ### Description of how you validated changes Ran on my fork of the repo (canceling the build workflow retriggers this one), see the following run for example: https://github.com/leonmk-aws/aws-cdk/actions/runs/17435786087/job/49505111010 ### Checklist - [X] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 640d88d commit 422e864

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

.github/workflows/pr-linter.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ jobs:
3434
- name: 'Download workflow_run artifact'
3535
if: github.event_name == 'workflow_run'
3636
uses: dawidd6/action-download-artifact@v11
37+
continue-on-error: true
3738
with:
3839
run_id: ${{ github.event.workflow_run.id }}
3940
name: pr_info
@@ -46,10 +47,10 @@ jobs:
4647
id: 'pr_output'
4748
run: |
4849
if [[ ! -f pr/pr_number ]]; then
49-
echo "${{ github.event.pull_request.number }}" > pr/pr_number
50+
echo "${{ github.event.workflow_run.pull_requests[0].number }}" > pr/pr_number
5051
fi
5152
if [[ ! -f pr/pr_sha ]]; then
52-
echo "${{ github.event.pull_request.head.sha }}" > pr/pr_sha
53+
echo "${{ github.event.workflow_run.head_sha }}" > pr/pr_sha
5354
fi
5455
cat pr/*
5556
echo "pr_number=$(cat pr/pr_number)" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)