From 7efa5096e9c5c60e4b3d1a6d5717a7cb7964b5cb Mon Sep 17 00:00:00 2001 From: Krishan Thisera Date: Fri, 10 Nov 2023 20:17:07 +1030 Subject: [PATCH] github action for docker build and push --- .github/workflows/docker.yaml | 50 +++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/docker.yaml diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml new file mode 100644 index 0000000..68cb271 --- /dev/null +++ b/.github/workflows/docker.yaml @@ -0,0 +1,50 @@ +name: Publish Docker image + +on: + push: + branches: + - main + release: + types: [published] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + IMAGE_TAG: ${{ github.sha }} + +jobs: + build-and-push-docker-image: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + include: + - docker_file: Dockerfile + image: ghcr.io/krishanthisera/grender + permissions: + contents: read + packages: write + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GHCR_TOKEN }} + + - name: Extract metadata for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ matrix.image }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + file: ${{ matrix.docker_file }} + context: ${{ matrix.context }} \ No newline at end of file