Skip to content

Commit b06d0ce

Browse files
differing before/after in update_build_env for opened/synchronized
1 parent 81d45d0 commit b06d0ce

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

.github/workflows/update_build_environment.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,23 @@ jobs:
1515
with:
1616
fetch-depth: '0'
1717
ref: ${{ github.head_ref }}
18-
- name: Print GitHub context for debugging
19-
env:
20-
GITHUB_CONTEXT: ${{ toJson(github) }}
21-
run: echo "$GITHUB_CONTEXT"
2218
- name: Check if Dockerfile needs to be rebuilt
2319
id: check-stale
2420
run: |
21+
echo "Checking if Dockerfile was modified since last commit on this PR"
2522
echo "GitHub PR action type: ${{ github.event.action }}"
26-
echo "Checking if the PR modifies the Dockerfile"
27-
echo "GitHub event before: ${{ github.event.before }}"
28-
echo "GitHub event after: ${{ github.event.after }}"
29-
if git diff --quiet ${{ github.event.before }} ${{ github.event.after }} Dockerfile; then
23+
if [ "${{ github.event.action }}" == "opened" ]; then
24+
echo "GitHub base ref: ${{ github.base_ref }}"
25+
echo "GitHub head ref: ${{ github.head_ref }}"
26+
BEFORE=${{ github.base_ref }}
27+
AFTER=${{ github.head_ref }}
28+
else
29+
echo "GitHub event before: ${{ github.event.before }}"
30+
echo "GitHub event after: ${{ github.event.after }}"
31+
BEFORE=${{ github.event.before }}
32+
AFTER=${{ github.event.after }}
33+
fi
34+
if git diff --quiet $BEFORE $AFTER Dockerfile; then
3035
echo "PR synchronized, but Dockerfile was not edited. Not rebuilding the image."
3136
echo "stale_dockerfile=false" >> "$GITHUB_OUTPUT"
3237
else

0 commit comments

Comments
 (0)