Skip to content

feat: build image in CI (#1) #1

feat: build image in CI (#1)

feat: build image in CI (#1) #1

Workflow file for this run

name: Build and Push Docker Image to GHCR
on:
push:
tags:
- 'v*.*.*' # Triggers on semantic version tags like v1.0.0
- 'v*.*.*-*' # Supports pre-release versions like v1.0.0-alpha.1
release:
types: [published] # Triggers when a release is published
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: qor5/linter
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=match,pattern=v(\d+\.\d+\.\d+)$,value=latest
flavor: |
latest=false
- name: Build and push Docker image
id: build
uses: docker/build-push-action@v5
with:
context: .
file: .docker/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Image digest
run: echo ${{ steps.build.outputs.digest }}