Skip to content

Commit

Permalink
Add Github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TobsA13 committed Mar 3, 2024
1 parent 86127cc commit 1bf8252
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/build_and_push_dockerimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Publish

on:
push:
branches:
- '**'
tags:
- 'v*'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
# define job to build and publish docker image
build-and-push-docker-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- 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 image and push to Docker Hub and GitHub Container Registry
id: build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Image digest
run: echo ${{ steps.build.outputs.digest }}

0 comments on commit 1bf8252

Please sign in to comment.