Skip to content

Commit 6b7555c

Browse files
fix comparison against merge base
i couldnt get this to work with a shallow clone. but i may just need to try harder
1 parent 086bbcd commit 6b7555c

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

.github/workflows/deploy-changed-samples.yml

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,22 @@ jobs:
2020
- name: Checkout code
2121
uses: actions/checkout@v4
2222
with:
23-
fetch-depth: 1
24-
25-
- name: Fetch main branch
26-
run: git fetch origin main:main # Fetch the main branch reference for comparison
23+
fetch-depth: 0
2724

2825
- name: Identify changed samples
2926
run: |
30-
# Identify the samples that have changed since the last commit on main
31-
# and save them to a file for later use.
32-
# remove paths to samples which have been renamed or deleted.
33-
git diff --name-only HEAD $(git merge-base main HEAD) \
27+
git fetch origin main
28+
LAST_ANCESTOR=$(git merge-base HEAD origin/main)
29+
git diff --name-only HEAD $LAST_ANCESTOR \
3430
| grep '^samples/' \
3531
| awk -F'/' '{print $1"/"$2}' \
3632
| sort \
37-
| uniq \
38-
| while read -r dir; do [ -d "$dir" ] && echo "$dir"; done > changed_samples.txt
39-
if [ ! -s changed_samples.txt ]; then
33+
| uniq > changed_samples.txt
34+
if [ -s changed_samples.txt ]; then
35+
echo "The following samples have changed:"
36+
cat changed_samples.txt
37+
else
4038
echo "No samples have changed. Exiting..."
41-
exit 0
4239
fi
4340
4441
- name: Install Golang

0 commit comments

Comments
 (0)