diff --git a/.gitea/workflows/docker-image.yml b/.gitea/workflows/docker-image.yml new file mode 100644 index 0000000..7128965 --- /dev/null +++ b/.gitea/workflows/docker-image.yml @@ -0,0 +1,81 @@ +name: Build and Push Docker Image to Gitea + +on: + push: + branches: + - master +env: + REGISTRY: git.apisb.me + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + # 1. Checkout the repository + - name: Checkout code + uses: actions/checkout@v4 + + # 2. Set up Docker Buildx + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + with: + config-inline: | + [registry."git.apisb.me"] + http = true + insecure = true + + # 3. Restore Docker Layer Cache + - name: Restore Docker cache + uses: actions/cache@v4.2.2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-docker-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-docker- + + # 4. Log in to Gitea Container Registry + - name: Log in to Gitea Container Registry + uses: docker/login-action@v2 + with: + registry: git.apisb.me + username: ${{ secrets.GITEA_USERNAME }} + password: ${{ secrets.GITEA_TOKEN }} + + # 5. Extract metadata (tags, labels) for Docker + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v9 + with: + images: git.apisb.me/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest + type=sha + + # 6. Build and push multi-platform Docker image + - name: Build and push multi-platform Docker image + id: push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max + + # 7. Generate artifact attestation + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v1 + with: + subject-name: git.apisb.me/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true