Skip to content

Add GitHub Actions workflow for building and pushing Docker image #1

Add GitHub Actions workflow for building and pushing Docker image

Add GitHub Actions workflow for building and pushing Docker image #1

name: Build and Push Docker Image
on:
push:
branches: ["main"]
workflow_dispatch:
jobs:
build-and-push:
runs-on: alpine-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: |
ghcr.io/${{ github.repository }}:latest
ghcr.io/${{ github.repository }}:${{ github.sha }}