ci: docker build

This commit is contained in:
Vasily Zubarev
2025-03-17 08:47:57 +01:00
parent 7ff5baf837
commit d42ab7ba86
5 changed files with 107 additions and 7 deletions

3
.github/FUNDING.yml vendored
View File

@@ -1,3 +1,2 @@
patreon: vas3k
ko_fi: vas3k
custom: ['https://vas3k.com/donate/', 'https://paypal.me/vas3kcom']
custom: ["https://vas3k.com/donate/", "https://paypal.me/vas3kcom"]

72
.github/workflows/docker-release.yml vendored Normal file
View File

@@ -0,0 +1,72 @@
name: Build and Publish Docker Image
on:
push:
tags:
- "v*"
jobs:
build-and-push:
name: Build and Push to GHCR
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
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: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Get release
id: get_release
uses: bruceadams/get-release@v1.3.2
env:
GITHUB_TOKEN: ${{ github.token }}
- name: Attach image to release
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const release_id = '${{ steps.get_release.outputs.id }}';
const tag_name = '${{ github.ref_name }}';
const image_name = 'ghcr.io/${{ github.repository }}:${{ github.ref_name }}';
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: release_id,
body: `Docker image: \`${image_name}\`\n\nAlso available as \`ghcr.io/${{ github.repository }}:latest\``
});
console.log(`Updated release ${release_id} with Docker image information`);