ci: Add Gitea workflow for Docker image release
This commit is contained in:
54
.gitea/workflows/build-image.yml
Normal file
54
.gitea/workflows/build-image.yml
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
name: Release Docker Image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*.*.*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
push_to_registries:
|
||||||
|
name: Push Docker image to Registry
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
packages: write
|
||||||
|
contents: read
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: git.danielvici.com
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract Docker tags
|
||||||
|
id: meta
|
||||||
|
run: |
|
||||||
|
version_tag="${{github.ref_name}}"
|
||||||
|
CLEAN_TAG=$(echo $version_tag | sed 's/^v//')
|
||||||
|
OWNER=$(echo "${{ github.repository_owner }}" | tr '[:upper:]' '[:lower:]')
|
||||||
|
REPO=$(echo "${{ github.event.repository.name }}" | tr '[:upper:]' '[:lower:]')
|
||||||
|
|
||||||
|
TAGS="git.danielvici.com/${OWNER}/${REPO}:${CLEAN_TAG}"
|
||||||
|
|
||||||
|
if [[ "$version_tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
TAGS="${TAGS},git.danielvici.com/${OWNER}/${REPO}:latest"
|
||||||
|
TAGS="${TAGS},git.danielvici.com/${OWNER}/${REPO}:$(echo $CLEAN_TAG | cut -d. -f1)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Build and push Docker images
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: true
|
||||||
|
platforms: linux/amd64
|
||||||
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
|
cache-from: type=gha
|
||||||
|
cache-to: type=gha,mode=max
|
||||||
Reference in New Issue
Block a user