From e51e26391fa45729ddbbf56aa9b0ca1779999ad9 Mon Sep 17 00:00:00 2001 From: Nuru Date: Fri, 24 May 2024 10:44:03 -0700 Subject: [PATCH] Push Docker image on release or manual build (#49) --- .github/workflows/docker.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 8c51206..4ae2d09 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -6,7 +6,7 @@ on: types: [opened, synchronize, reopened] release: types: - - created + - published schedule: - cron: '30 23 * * *' @@ -17,7 +17,7 @@ jobs: - name: "Checkout source code at current commit" uses: actions/checkout@v4 - name: Prepare tags for Docker image - if: (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' + if: (github.event_name == 'release' && github.event.action == 'published') || github.event.pull_request.head.repo.full_name == github.repository || (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') id: prepare run: | TAGS=${{ github.repository }}:sha-${GITHUB_SHA:0:7} @@ -34,12 +34,14 @@ jobs: fi if [[ ${{ github.event_name }} == 'schedule' ]]; then TAGS="$TAGS,${{ github.repository }}:latest,${{ github.repository }}:nightly" + elif [[ $GITHUB_REF != refs/pull/* ]]; then + TAGS="$TAGS,${{ github.repository }}:latest" fi echo "tags=${TAGS}" >> $GITHUB_OUTPUT - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to DockerHub - if: (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' + if: (github.event_name == 'release' && github.event.action == 'published') || github.event.pull_request.head.repo.full_name == github.repository || (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -48,5 +50,5 @@ jobs: id: docker_build uses: docker/build-push-action@v5 with: - push: ${{ (github.event_name == 'release' && github.event.action == 'created') || github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'schedule' }} + push: ${{ (github.event_name == 'release' && github.event.action == 'published') || github.event.pull_request.head.repo.full_name == github.repository || (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} tags: ${{ steps.prepare.outputs.tags }}