Skip to content

Commit 0594bdd

Browse files
authored
Merge pull request #547 from ExperienceLovelace/bugfix/dev_workflow_check
Simplify the base and head check
2 parents 9cc4217 + d2b75a7 commit 0594bdd

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

.github/workflows/pr-validation.yaml

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,32 +14,15 @@ jobs:
1414
with:
1515
fetch-depth: 0
1616

17-
- name: Debug - Show git diff
18-
run: |
19-
echo "Base ref: origin/${{ github.base_ref }}"
20-
echo "Head ref: origin/${{ github.head_ref }}"
21-
git diff --name-only origin/${{ github.base_ref }} origin/${{ github.head_ref }}
22-
23-
2417
- name: Check if workflows folder is modified
2518
id: check-workflows
2619
run: |
2720
set -e # Exit immediately if a command exits with a non-zero status
28-
echo "workflow_modified=undefined" >> $GITHUB_ENV
29-
git fetch --no-tags --prune --depth=2 origin +refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }} +refs/heads/${{ github.head_ref }}:refs/remotes/origin/${{ github.head_ref }}
30-
31-
# Check if there is a merge base
32-
if git merge-base origin/${{ github.base_ref }} origin/${{ github.head_ref }} > /dev/null 2>&1; then
33-
# Compare changes if a merge base exists
34-
if git diff --name-only origin/${{ github.base_ref }} origin/${{ github.head_ref }} | grep -q '^.github/workflows/'; then
35-
echo "workflows_modified=true" >> $GITHUB_ENV
36-
else
37-
echo "workflows_modified=false" >> $GITHUB_ENV
38-
fi
39-
else
40-
# No merge base, assume workflows are modified
41-
echo "No merge base found between branches. Assuming workflows are modified."
21+
git fetch --no-tags --depth=2 origin ${{ github.base_ref }} ${{ github.head_ref }}
22+
if git diff --name-only origin/${{ github.base_ref }} origin/${{ github.head_ref }} | grep -q '^.github/workflows/'; then
4223
echo "workflows_modified=true" >> $GITHUB_ENV
24+
else
25+
echo "workflows_modified=false" >> $GITHUB_ENV
4326
fi
4427
4528
- name: "Fail if workflows folder is not checked"

0 commit comments

Comments
 (0)