Skip to content

Commit

Permalink
fix: GIT_DIFF in the docker workflow. (#3201)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fastfadingviolets authored Jul 15, 2024
1 parent 74fc7c6 commit 9b91732
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions .github/workflows/docker-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,13 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- uses: technote-space/[email protected]
id: git_diff
with:
PATTERNS: |
**/*.go
go.mod
go.sum
**/go.mod
**/go.sum
**/Makefile
Makefile
Dockerfile
- name: Get new commits for nightly build
run: echo "NEW_COMMIT_COUNT=$(git log --oneline --since '24 hours ago' | wc -l)" >> $GITHUB_ENV
if: "${{ env.GITHUB_EVENT_NAME == 'schedule' }}"

- name: Set new commits for other builds
run: echo "NEW_COMMIT_COUNT=1" >> $GITHUB_ENV
if: "${{ env.GITHUB_EVENT_NAME != 'schedule' }}"

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

0 comments on commit 9b91732

Please sign in to comment.