chore: Add GitHub Actions workflow for Docker build

This commit is contained in:
Chris Kacerguis
2025-10-08 07:51:06 -05:00
committed by GitHub
parent 3e8a1b3e4a
commit db24d29922
+66
View File
@@ -0,0 +1,66 @@
name: Build Docker Image
on:
push:
branches: [main]
tags: ["v*", "*.*.*"]
pull_request:
branches: [main]
workflow_dispatch: {}
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
env:
IMAGE_NAME: mkcertweb
jobs:
build-and-push:
name: Build and Push Image
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=sha
type=ref,event=tag
labels: |
org.opencontainers.image.source=${{ github.repository }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max