Files
FabledScribe/.forgejo/workflows/build.yml
T
bvandeusen 02df3a4be4 Add dev branch support to build workflow
dev push  → :dev + :<sha>
main push → :latest + :<sha>
tag push  → :latest + :<sha> + :<version>

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-08 21:17:53 -04:00

68 lines
2.0 KiB
YAML

# Branch push (dev): builds and pushes :dev + :<sha>
# Branch push (main): builds and pushes :latest + :<sha>
# Tag push (v1.2.0): builds and pushes :latest + :<sha> + :v1.2.0
#
# To cut a versioned release:
# git tag v1.2.0 && git push origin v1.2.0
#
# Required secrets (repo → Settings → Secrets → Actions):
# REGISTRY_USER — your Forgejo username
# REGISTRY_TOKEN — Forgejo PAT with write:packages scope
name: Build & push image
on:
push:
branches: [main, dev]
tags: ["v*"]
paths:
- "src/**"
- "frontend/**"
- "Dockerfile"
- "pyproject.toml"
- "alembic/**"
- "alembic.ini"
- ".forgejo/workflows/build.yml"
env:
REGISTRY: git.fabledsword.com
IMAGE: git.fabledsword.com/bvandeusen/fabledassistant
jobs:
build:
name: Build & push
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate image tags
id: tags
run: |
TAGS="${{ env.IMAGE }}:${{ github.sha }}"
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
TAGS="$TAGS,${{ env.IMAGE }}:latest"
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
TAGS="$TAGS,${{ env.IMAGE }}:dev"
elif [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAGS="$TAGS,${{ env.IMAGE }}:latest,${{ env.IMAGE }}:${{ github.ref_name }}"
fi
echo "value=$TAGS" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Forgejo registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.tags.outputs.value }}
cache-from: type=registry,ref=${{ env.IMAGE }}:cache
cache-to: type=registry,ref=${{ env.IMAGE }}:cache,mode=max