Skip to content

Commit bdf2045

Browse files
feat: add manual Docker publish with ref/tag inputs
- Add workflow_dispatch inputs for ref (branch/tag/SHA) and custom tag - Checkout specified ref for manual builds - Include OAuth credentials in all Docker builds - Allow disabling push for build-only testing
1 parent a233bc4 commit bdf2045

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

.github/workflows/docker-publish.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,21 @@ on:
1616
branches: ["main", "next"]
1717
workflow_dispatch:
1818
inputs:
19-
description:
20-
required: false
21-
description: "Description of the run."
22-
type: string
23-
default: "Manual run"
19+
ref:
20+
description: "Git ref to build (branch, tag, or SHA). Leave empty for default branch."
21+
required: false
22+
type: string
23+
default: ""
24+
tag:
25+
description: "Custom image tag (e.g., 'test-oauth', 'pr-1836'). Required for manual runs."
26+
required: false
27+
type: string
28+
default: ""
29+
push:
30+
description: "Push to registry"
31+
required: false
32+
type: boolean
33+
default: true
2434

2535
env:
2636
# Use docker.io for Docker Hub if empty
@@ -41,6 +51,8 @@ jobs:
4151
steps:
4252
- name: Checkout repository
4353
uses: actions/checkout@v6
54+
with:
55+
ref: ${{ inputs.ref || github.ref }}
4456

4557
# Install the cosign tool except on PR
4658
# https://github.com/sigstore/cosign-installer
@@ -83,6 +95,8 @@ jobs:
8395
type=semver,pattern={{major}}
8496
type=sha
8597
type=edge
98+
# Custom tag for manual workflow dispatch
99+
type=raw,value=${{ inputs.tag }},enable=${{ inputs.tag != '' }}
86100
# Custom rule to prevent pre-releases from getting latest tag
87101
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
88102
@@ -104,14 +118,14 @@ jobs:
104118
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
105119
with:
106120
context: .
107-
push: ${{ github.event_name != 'pull_request' }}
121+
push: ${{ github.event_name != 'pull_request' && (github.event_name != 'workflow_dispatch' || inputs.push) }}
108122
tags: ${{ steps.meta.outputs.tags }}
109123
labels: ${{ steps.meta.outputs.labels }}
110124
cache-from: type=gha
111125
cache-to: type=gha,mode=max
112126
platforms: linux/amd64,linux/arm64
113127
build-args: |
114-
VERSION=${{ github.ref_name }}
128+
VERSION=${{ inputs.ref || github.ref_name }}
115129
OAUTH_CLIENT_ID=${{ secrets.OAUTH_CLIENT_ID }}
116130
OAUTH_CLIENT_SECRET=${{ secrets.OAUTH_CLIENT_SECRET }}
117131

0 commit comments

Comments
 (0)