Skip to content

feat: add docker support (#1) #1

feat: add docker support (#1)

feat: add docker support (#1) #1

Workflow file for this run

name: Build Docker image
on:
pull_request:
branches: [main]
push:
branches: [main]
tags: [v*]
paths-ignore:
- "**/*.md"
- LICENSE
workflow_dispatch:
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Setup QEMU
id: qemu
uses: docker/setup-qemu-action@v3
with:
platforms: |
linux/amd64
linux/arm64
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Login to Docker Hub
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=ref,event=branch
type=ref,event=tag
- name: Build and Push
uses: docker/build-push-action@v5
with:
push: ${{ github.event_name != 'pull_request' }}
target: production
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
platforms: ${{ steps.qemu.outputs.platforms }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
- name: Delete Untagged Packages
uses: dataaxiom/ghcr-cleanup-action@v1
with:
token: ${{ github.token }}