name: Build and Push Docker Image on: push: branches: - main workflow_dispatch: # Manual trigger env: REGISTRY: ${{ vars.REGISTRY_HOST }} # Set in Gitea repo settings, e.g., gitea.local IMAGE_NAME: ${{ gitea.repository }} # e.g., username/ghbot jobs: build-and-push: runs-on: ubuntu-latest # Or your self-hosted runner label steps: - name: Checkout repository uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to Gitea Container Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ gitea.actor }} password: ${{ secrets.REGISTRY_TOKEN }} - name: Extract metadata (tags, labels) id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=raw,value=latest,enable={{is_default_branch}} type=sha,prefix= type=ref,event=branch - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max