Skip to content

Commit

Permalink
github action for docker build and push
Browse files Browse the repository at this point in the history
  • Loading branch information
krishanthisera committed Nov 10, 2023
1 parent d119172 commit 0bd4c00
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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
context: backend
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 }}

0 comments on commit 0bd4c00

Please sign in to comment.