From 7e151b33b97cf12111b4ffee6dc54d1a6e929080 Mon Sep 17 00:00:00 2001 From: Kshitij Raj Sharma <36752999+kshitijrajsharma@users.noreply.github.com> Date: Mon, 25 Nov 2024 19:28:20 +0100 Subject: [PATCH] Create build-push-docker-on-master.yml --- .../workflows/build-push-docker-on-master.yml | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/build-push-docker-on-master.yml diff --git a/.github/workflows/build-push-docker-on-master.yml b/.github/workflows/build-push-docker-on-master.yml new file mode 100644 index 0000000..6986db5 --- /dev/null +++ b/.github/workflows/build-push-docker-on-master.yml @@ -0,0 +1,39 @@ +name: Create and publish a Docker image + +on: + push: + branches: ["master"] + workflow_dispatch: +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@v1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v3 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v2 + with: + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}