Skip to content

Speakr is a personal, self-hosted web application designed for transcribing audio recordings

Python

Forgejo CI: make Docker build manual-only (workflow_dispatch w/ tag + push toggle, default no-push)

Murtaza Nasir476e65a96fc2
diff --git a/.forgejo/workflows/docker-publish.yml b/.forgejo/workflows/docker-publish.yml
index f9c823ec..6d3aa96d 100644
--- a/.forgejo/workflows/docker-publish.yml
+++ b/.forgejo/workflows/docker-publish.yml
@@ -1,14 +1,22 @@
name: Docker Build and Publish
-# Forgejo Actions version. Triggers ONLY on version tags and manual dispatch so
-# the heavy multi-arch (amd64 + emulated arm64) PyTorch build never runs on every
-# push to this homelab runner. Pushes to Docker Hub (learnedmachine/speakr) using
-# the DOCKERHUB_USERNAME / DOCKERHUB_TOKEN secrets configured on the repo.
+# MANUAL-ONLY. This workflow is never triggered by a push, tag, or merge.
+# Images are built and/or pushed ONLY when you start it yourself from the
+# Actions tab ("Run workflow") or via the API, choosing the tag and whether to
+# actually push. Default is a build-only dry run (push: false) so nothing is
+# published unless you explicitly opt in.
on:
- push:
- tags: [ 'v*.*.*' ]
workflow_dispatch:
+ inputs:
+ image_tag:
+ description: "Image tag to publish (e.g. v0.6.0 or latest)"
+ required: true
+ default: latest
+ push:
+ description: "Push to Docker Hub? Leave off for a build-only dry run."
+ type: boolean
+ default: false
env:
REGISTRY: docker.io
@@ -69,30 +77,20 @@ jobs:
uses: docker/setup-buildx-action@v3
- name: Log into Docker Hub
+ if: ${{ inputs.push }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- - name: Extract Docker metadata
- id: meta
- uses: docker/metadata-action@v5
- with:
- images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- tags: |
- type=match,pattern=v(.*),group=1
- type=sha
- type=raw,value=latest,enable=${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }}
-
- - name: Build and push Docker image
+ - name: Build (and optionally push) image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
- push: true
- tags: ${{ steps.meta.outputs.tags }}
- labels: ${{ steps.meta.outputs.labels }}
+ push: ${{ inputs.push }}
+ tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.image_tag }}
build-args: |
PRODUCTION=1
@@ -111,30 +109,20 @@ jobs:
uses: docker/setup-buildx-action@v3
- name: Log into Docker Hub
+ if: ${{ inputs.push }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- - name: Extract Docker metadata (lite)
- id: meta-lite
- uses: docker/metadata-action@v5
- with:
- images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- tags: |
- type=raw,value=lite,enable=${{ github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') }}
- type=match,pattern=v(.*),group=1,suffix=-lite
- type=sha,suffix=-lite
-
- - name: Build and push lite Docker image
+ - name: Build (and optionally push) lite image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
- push: true
- tags: ${{ steps.meta-lite.outputs.tags }}
- labels: ${{ steps.meta-lite.outputs.labels }}
+ push: ${{ inputs.push }}
+ tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.image_tag }}-lite
build-args: |
PRODUCTION=1
LIGHTWEIGHT=1