From 427965eb1bb48c1b3b74aee42e0f10fd3dbbb43e Mon Sep 17 00:00:00 2001 From: Admin9705 <9705@duck.com> Date: Sun, 8 Jun 2025 07:47:09 -0400 Subject: [PATCH] chore: update Docker workflow to allow builds on dev branch, add manual trigger option, and refine push conditions --- .github/workflows/docker-build-push.yml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 43919a21..fc1313d2 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -3,14 +3,21 @@ name: Build and Push Docker Image on: push: branches: - - main - - master + - dev # Only auto-build on dev branch tags: - - 'v*' + - 'v*' # Still allow tagged releases pull_request: branches: - main - master + - dev + workflow_dispatch: # Allow manual triggering + inputs: + force_push: + description: 'Force push to registries (even from main branch)' + required: false + default: false + type: boolean permissions: contents: read @@ -47,7 +54,7 @@ jobs: # Login to DockerHub - name: Login to DockerHub - if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' && (github.ref != 'refs/heads/main' || github.event.inputs.force_push == 'true' || startsWith(github.ref, 'refs/tags/')) uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -55,7 +62,7 @@ jobs: # Login to GitHub Container Registry - name: Login to GitHub Container Registry - if: github.event_name != 'pull_request' + if: github.event_name != 'pull_request' && (github.ref != 'refs/heads/main' || github.event.inputs.force_push == 'true' || startsWith(github.ref, 'refs/tags/')) uses: docker/login-action@v3 with: registry: ghcr.io @@ -68,7 +75,8 @@ jobs: with: context: . platforms: linux/amd64,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} + # Only push if not a PR AND (not main branch OR manual force OR tagged release) + push: ${{ github.event_name != 'pull_request' && (github.ref != 'refs/heads/main' || github.event.inputs.force_push == 'true' || startsWith(github.ref, 'refs/tags/')) }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha