69 lines
1.5 KiB
YAML
69 lines
1.5 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
release:
|
|
types:
|
|
- created
|
|
|
|
push:
|
|
tags:
|
|
- "v[0-9]+.[0-9]+.[0-9]+"
|
|
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
REGISTRY: ghcr.io
|
|
|
|
jobs:
|
|
build:
|
|
name: Build and push container
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
attestations: write
|
|
id-token: write
|
|
strategy:
|
|
matrix:
|
|
platform:
|
|
- linux/amd64
|
|
steps:
|
|
- name: Set repository and image name
|
|
run: |
|
|
echo "FULL_IMAGE_NAME=${{ env.REGISTRY }}/${IMAGE_NAME,,}" >>${GITHUB_ENV}
|
|
env:
|
|
IMAGE_NAME: "${{ github.repository }}"
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
id: buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Set up Docker meta
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ env.FULL_IMAGE_NAME }}
|
|
|
|
- name: Log in to the Container registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ env.REGISTRY }}
|
|
username: ${{ github.actor }}
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Build docker image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
file: Dockerfile
|
|
context: .
|
|
push: true
|
|
platforms: ${{ matrix.platform }}
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|
|
load: true
|