Skip to content

Commit 3461588

Browse files
authored
Merge pull request #37492 from openedx/feanil/update_requirements_consistency_workflow
build: Refactor GitHub Actions workflow for dependencies
2 parents 87c8e55 + 542b6f8 commit 3461588

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

.github/workflows/check-consistent-dependencies.yml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,30 @@ jobs:
1919
runs-on: ubuntu-24.04
2020

2121
steps:
22+
# Always checkout the code because we don't always have a PR url.
23+
- uses: actions/checkout@v5
24+
2225
# Only run remaining steps if there are changes to requirements/**
26+
# We do this instead of using path based short-circuiting.
27+
# see https://stackoverflow.com/questions/77996177/how-can-i-handle-a-required-check-that-isnt-always-triggered
28+
# for some more details.
2329
- name: "Decide whether to short-circuit"
24-
env:
25-
GH_TOKEN: "${{ github.token }}"
26-
PR_URL: "${{ github.event.pull_request.html_url }}"
2730
run: |
28-
paths=$(gh pr diff "$PR_URL" --name-only)
29-
echo $'Paths touched in PR:\n'"$paths"
31+
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
32+
BASE_SHA="${{ github.event.pull_request.base.sha }}"
33+
else
34+
BASE_SHA="${{ github.event.merge_group.base_sha }}"
35+
fi
36+
37+
# Fetch the base sha so we can compare to it. It's not checked out by
38+
# default.
39+
git fetch origin "$BASE_SHA"
3040
3141
# The ^"? is because git may quote weird file paths
32-
matched="$(echo "$paths" | grep -P '^"?((requirements/)|(scripts/.*?/requirements/))' || true)"
33-
echo $'Relevant paths:\n'"$matched"
34-
if [[ -n "$matched" ]]; then
35-
echo "RELEVANT=true" >> "$GITHUB_ENV"
42+
if git diff --name-only "$BASE_SHA" | grep -P '^"?((requirements/)|(scripts/.*?/requirements/))'; then
43+
echo "RELEVANT=true" >> "$GITHUB_ENV"
3644
fi
3745
38-
- uses: actions/checkout@v5
39-
if: ${{ env.RELEVANT == 'true' }}
40-
4146
- uses: actions/setup-python@v5
4247
if: ${{ env.RELEVANT == 'true' }}
4348
with:

0 commit comments

Comments
 (0)