From 9b917326d4f50bc352e04b2f1c385dc8946e65ee Mon Sep 17 00:00:00 2001 From: violet <158512193+fastfadingviolets@users.noreply.github.com> Date: Mon, 15 Jul 2024 05:12:04 -0400 Subject: [PATCH] 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. --- .github/workflows/docker-push.yml | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/.github/workflows/docker-push.yml b/.github/workflows/docker-push.yml index fed4f1bff6d..aeb5c0fa51a 100644 --- a/.github/workflows/docker-push.yml +++ b/.github/workflows/docker-push.yml @@ -23,18 +23,13 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - uses: technote-space/get-diff-action@v6.1.2 - 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/login-action@v3.2.0 @@ -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 }}