diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f9e3841..f4c569d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,8 @@ on: env: GO_VERSION: "1.23.3" REPOSITORY: flannel/flannel-cni-plugin + IMAGE_NAME: flannel-io/flannel-cni-plugin + REGISTRY: ghcr.io jobs: build-and-release: @@ -93,3 +95,53 @@ jobs: push: true platforms: linux/amd64,linux/arm64,linux/arm,linux/s390x,linux/ppc64le,linux/riscv64 tags: ${{ steps.meta.outputs.tags }} + + build-and-push-images-github-registry: + needs: [build-and-release] + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + attestations: write + id-token: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=ref,event=tag + + - name: Build and push Docker image + id: push + uses: docker/build-push-action@v5 + with: + context: . + file: Dockerfile.image + push: true + platforms: linux/amd64,linux/arm64,linux/arm,linux/s390x,linux/ppc64le,linux/riscv64 + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: REGISTRY=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Generate artifact attestation + uses: actions/attest-build-provenance@v2 + with: + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + subject-digest: ${{ steps.push.outputs.digest }} + push-to-registry: true