From e2d8e05ca1f67b68514a8d31ab793882b0138722 Mon Sep 17 00:00:00 2001 From: Yasumasa Suenaga Date: Sat, 25 Mar 2023 11:51:59 +0900 Subject: [PATCH] Add workflow for publishing container image Relates to #252 and #326 Signed-off-by: Yasumasa Suenaga --- .github/workflows/2-release.yaml | 47 ++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/2-release.yaml diff --git a/.github/workflows/2-release.yaml b/.github/workflows/2-release.yaml new file mode 100644 index 000000000..f926b6de6 --- /dev/null +++ b/.github/workflows/2-release.yaml @@ -0,0 +1,47 @@ +name: Publish container image to GitHub Packages + +on: + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +concurrency: + group: publish + cancel-in-progress: true + +jobs: + publish-container-image: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Log in to the Container registry + uses: docker/login-action@v2.1.0 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ github.token }} + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4.3.0 + with: + tags: type=raw,value=${{ github.ref_name }} + flavor: latest=true + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + - name: Build and push Docker image + uses: docker/build-push-action@v4.0.0 + with: + context: "{{defaultContext}}:src" + file: CarbonAware.WebApi/src/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + provenance: false