@@ -15,18 +15,23 @@ jobs:
15
15
with :
16
16
fetch-depth : ' 0'
17
17
ref : ${{ github.head_ref }}
18
- - name : Print GitHub context for debugging
19
- env :
20
- GITHUB_CONTEXT : ${{ toJson(github) }}
21
- run : echo "$GITHUB_CONTEXT"
22
18
- name : Check if Dockerfile needs to be rebuilt
23
19
id : check-stale
24
20
run : |
21
+ echo "Checking if Dockerfile was modified since last commit on this PR"
25
22
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
30
35
echo "PR synchronized, but Dockerfile was not edited. Not rebuilding the image."
31
36
echo "stale_dockerfile=false" >> "$GITHUB_OUTPUT"
32
37
else
0 commit comments