Skip to content

Commit 9b91732

Browse files
fix: GIT_DIFF in the docker workflow. (#3201)
It turns out the get-diff-action only works on `push` and `pull_request` events, and will report an empty diff otherwise. This makes it so that we only run nightly builds if there's been a commit in the last 24h. Builds from workflow_dispatch and releases are always triggered.
1 parent 74fc7c6 commit 9b91732

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

.github/workflows/docker-push.yml

+8-13
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,13 @@ jobs:
2323
- name: Checkout repository
2424
uses: actions/checkout@v4
2525

26-
- uses: technote-space/[email protected]
27-
id: git_diff
28-
with:
29-
PATTERNS: |
30-
**/*.go
31-
go.mod
32-
go.sum
33-
**/go.mod
34-
**/go.sum
35-
**/Makefile
36-
Makefile
37-
Dockerfile
26+
- name: Get new commits for nightly build
27+
run: echo "NEW_COMMIT_COUNT=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_ENV
28+
if: "${{ env.GITHUB_EVENT_NAME == 'schedule' }}"
29+
30+
- name: Set new commits for other builds
31+
run: echo "NEW_COMMIT_COUNT=1" >> $GITHUB_ENV
32+
if: "${{ env.GITHUB_EVENT_NAME != 'schedule' }}"
3833

3934
- name: Log in to the Container registry
4035
uses: docker/[email protected]
@@ -58,4 +53,4 @@ jobs:
5853
push: true
5954
tags: ${{ steps.meta.outputs.tags }}
6055
labels: ${{ steps.meta.outputs.labels }}
61-
if: env.GIT_DIFF
56+
if: ${{ env.NEW_COMMIT_COUNT > 0 }}

0 commit comments

Comments
 (0)