# Runs only on pushes to main. # Builds the Docker image and pushes it to the Forgejo container registry. # Registry-side layer caching means unchanged layers (npm install, pip install) # are reused between builds — typically cuts build time from ~4 min to ~45 sec. # # The resulting image can then be deployed manually via Portainer. # # Required secrets (repo → Settings → Secrets → Actions): # REGISTRY_USER — your Forgejo username # REGISTRY_TOKEN — Forgejo PAT with write:packages scope (create at # git.fabledsword.com → Settings → Applications → Generate Token) name: Build & push image on: push: branches: [main] 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: 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: | ${{ env.IMAGE }}:latest ${{ env.IMAGE }}:${{ github.sha }} cache-from: type=registry,ref=${{ env.IMAGE }}:cache cache-to: type=registry,ref=${{ env.IMAGE }}:cache,mode=max