Skip to content

Commit a3fcc32

Browse files
committed
Fix check-gh-aw-lockfiles to use PR files API instead of git diff
A 3-dot `git diff base.sha...HEAD` over-includes upstream changes that entered the PR branch via merges from main, which falsely triggers the gh-aw compile and fails the lockfile check on PRs that did not modify any gh-aw inputs. Use the GitHub PR files API instead, which returns the canonical list of files actually changed by the PR.
1 parent 11369bc commit a3fcc32

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

.github/workflows/build-common.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,23 @@ jobs:
188188
- name: Determine workflows to compile
189189
id: workflows
190190
shell: bash
191+
env:
192+
GH_TOKEN: ${{ github.token }}
193+
PR_NUMBER: ${{ github.event.pull_request.number }}
191194
run: |
192195
set -euo pipefail
193196
194197
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
198+
# Use the GitHub API to get the actual list of files changed in the
199+
# PR. A `git diff base.sha...HEAD` would over-include changes that
200+
# entered the branch via merges from main, which can falsely trigger
201+
# a compile when the PR did not actually modify any gh-aw inputs.
195202
mapfile -t changed_files < <(
196-
git diff --name-only "${{ github.event.pull_request.base.sha }}"...HEAD -- \
197-
".github/workflows/*.md" \
198-
".github/workflows/*.lock.yml" \
199-
".github/agents/**" \
200-
".github/aw/**"
203+
gh api --paginate \
204+
"repos/${{ github.repository }}/pulls/${PR_NUMBER}/files" \
205+
--jq '.[].filename' \
206+
| grep -E '^\.github/(workflows/.*\.(md|lock\.yml)|agents/|aw/)' \
207+
|| true
201208
)
202209
else
203210
mapfile -t changed_files < <(find .github/workflows -maxdepth 1 -name "*.md" | sort)

0 commit comments

Comments
 (0)