# Branch push (dev): builds and pushes :dev + : # Branch push (main): builds and pushes :latest + : # Tag push (v1.2.0): builds and pushes :latest + : + :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