Skip to content

Commit 3026731

Browse files
committed
github actions: Allow fork checkout for commit validation
Since we have external contributors we need process each of the commits for faster reviews, validation that header information is correct and to check the state of our tickets so that is actually tracked correctly internally, on behalf of some external contributors. In addition the order of steps was reordered so the clone and checkout of the base repo and base branch was done first then the PR's were fetched and checked out next. This to ensure that our repo is the base of everything rather than the PR's repo which could be an external contributor.
1 parent e60193a commit 3026731

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

.github/workflows/validate-kernel-commits.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@ jobs:
1414
timeout-minutes: 120
1515

1616
steps:
17-
- name: Checkout PR branch
17+
- name: Checkout base branch
1818
uses: actions/checkout@v4
1919
with:
2020
fetch-depth: 0
21-
ref: ${{ github.head_ref }}
21+
ref: ${{ github.base_ref }}
2222

23-
- name: Checkout base branch
23+
- name: Fetch PR branch
2424
run: |
25-
git fetch origin "${{ github.base_ref }}":"${{ github.base_ref }}"
25+
git fetch "${{ github.event.pull_request.head.repo.clone_url }}" "${{ github.head_ref }}"
26+
echo "HEAD_SHA=$(git rev-parse FETCH_HEAD)" >> "$GITHUB_ENV"
2627
2728
- name: Checkout kernel-src-tree-tools
2829
uses: actions/checkout@v4
@@ -44,7 +45,7 @@ jobs:
4445
set -o pipefail # Capture exit code from python script, not tee
4546
python3 check_kernel_commits.py \
4647
--repo .. \
47-
--pr_branch "${{ github.head_ref }}" \
48+
--pr_branch "$HEAD_SHA" \
4849
--base_branch "${{ github.base_ref }}" \
4950
--markdown \
5051
--check-cves | tee ../ckc_result.txt
@@ -108,7 +109,7 @@ jobs:
108109
set -o pipefail # Capture exit code from python script, not tee
109110
python3 run_interdiff.py \
110111
--repo .. \
111-
--pr_branch "${{ github.head_ref }}" \
112+
--pr_branch "$HEAD_SHA" \
112113
--base_branch "${{ github.base_ref }}" \
113114
--markdown \
114115
--interdiff ../patchutils/src/interdiff | tee ../interdiff_result.txt
@@ -177,7 +178,7 @@ jobs:
177178
OUTPUT=$(python3 jira_pr_check.py \
178179
--kernel-src-tree .. \
179180
--merge-target "${{ github.base_ref }}" \
180-
--pr-branch "${{ github.head_ref }}" 2>&1)
181+
--pr-branch "$HEAD_SHA" 2>&1)
181182
EXIT_CODE=$?
182183
183184
# Filter out any potential credential leaks from output

0 commit comments

Comments
 (0)