From b601050784a41aa9616b888aa98dbfdc5a78abd1 Mon Sep 17 00:00:00 2001 From: Paul Yu Date: Fri, 5 May 2023 02:54:46 +0000 Subject: [PATCH] ci: add container-image.yml for building and pushing container to ghcr.io --- .github/workflows/container-image.yml | 45 +++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .github/workflows/container-image.yml diff --git a/.github/workflows/container-image.yml b/.github/workflows/container-image.yml new file mode 100644 index 0000000..c397cc8 --- /dev/null +++ b/.github/workflows/container-image.yml @@ -0,0 +1,45 @@ +name: Build and push container image + +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + packages: write + +# docker buildx to build and push multi-arch images +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Docker Setup Buildx + uses: docker/setup-buildx-action@v2 + with: + platforms: linux/amd64,linux/arm64/v8 + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ github.token }} + - name: Lowercase repo name + id: repository + run: | + echo "LOWERCASE_REPO=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT + - name: Build and push using docker Buildx + uses: docker/build-push-action@v2 + with: + context: . + file: ./Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ghcr.io/${{ steps.repository.outputs.LOWERCASE_REPO }}:${{ github.sha }},ghcr.io/${{ steps.repository.outputs.LOWERCASE_REPO }}:latest