first commit

This commit is contained in:
2025-11-11 12:41:04 +01:00
commit ba3ec728bc
3 changed files with 177 additions and 0 deletions

View File

@@ -0,0 +1,80 @@
---
name: Docker Build
on:
workflow_call:
inputs:
dockerfile:
description: 'Path to Dockerfile'
required: true
type: string
context:
description: 'Build context'
default: '.'
required: false
image:
description: 'Where to store the built image'
required: true
type: string
submodules:
description: 'Submodules pull strategy'
default: 'recursive'
required: false
type: string
user:
description: 'Git user for checkout'
default: 'automation'
required: false
type: string
token:
description: 'Git token for checkout'
required: true
type: string
outputs:
tag:
description: 'Built image tag'
value: ${{ steps.build.outputs.tag }}
image:
description: 'Built image name'
value: ${{ steps.build.outputs.image }}
sha:
description: 'Git SHA used for the build'
value: ${{ steps.build.outputs.sha }}
jobs:
build:
name: Build Docker Image
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: ${{ inputs.submodules }}
token: "${{ inputs.token }}"
- name: Gather registry metadata
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ inputs.image }}
tags: |
type=sha,prefix=,suffix=,format=long
- name: Registry login
uses: docker/login-action@v3
with:
registry: git.etc.nu
username: "${{ inputs.user }}"
password: "${{ inputs.token }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push image
uses: docker/build-push-action@v6
id: build
with:
file: ${{ inputs.dockerfile }}
context: ${{ inputs.context }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=${{ inputs.image }}/cache
cache-to: type=registry,ref=${{ inputs.image }}/cache,mode=max
outputs:
tag: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
image: ${{ inputs.image }}
sha: ${{ gitea.sha }}

View File

@@ -0,0 +1,59 @@
---
name: Docker Tag Release
on:
workflow_call:
inputs:
environment:
description: 'Environment to release in'
type: string
required: true
image:
description: 'Where to store the built image'
required: true
type: string
user:
description: 'Git user for checkout'
default: 'automation'
required: false
type: string
token:
description: 'Git token for checkout'
required: true
type: string
outputs:
tag:
description: 'Release image tag'
value: ${{ steps.release.outputs.tag }}
tag_name:
description: 'Release image tag name'
value: ${{ steps.release.outputs.tag_name }}
jobs:
release:
name: Release
steps:
- name: Create metadata
id: meta
run: |
echo tag_name=${{ inputs.environment }}-$(date +%F-%H%M%S)-${{ gitea.sha }} > $GITHUB_OUTPUT
- name: Registry login
uses: docker/login-action@v3
with:
registry: git.etc.nu
username: "${{ inputs.user }}"
password: "${{ inputs.token }}"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
install: true
version: v0.26.1
- name: Push tag
id: push
run: |
TAG=${{ inputs.image }}:${{ steps.meta.outputs.tag_name }}
docker buildx imagetools --debug create \
--tag $TAG \
${{ inputs.image }}:${{ gitea.sha }}
echo tag=$TAG >> $GITHUB_OUTPUT
outputs:
tag: ${{ steps.push.outputs.tag }}
tag_name: ${{ steps.meta.outputs.tag_name }}

View File

@@ -0,0 +1,38 @@
---
name: Gitea Create Release
on:
workflow_call:
inputs:
token:
description: "Token for authentication"
required: true
type: string
outputs:
name:
description: "Release name"
value: ${{ jobs.create-release.outputs.name }}
tag_name:
description: "Release tag name"
value: ${{ jobs.create-release.outputs.tag_name }}
jobs:
create-release:
name: Create Release
steps:
- id: facts
run: |
tag_name=$(date +%F-%H%M%S)
echo name="Release ${tag_name}" >> $GITHUB_OUTPUT
echo tag_name=${tag_name} >> $GITHUB_OUTPUT
- uses: https://gitea.com/actions/gitea-release-action@v1
with:
name: ${{ steps.facts.outputs.name }}
tag_name: ${{ steps.facts.outputs.tag_name }}
body: |
Automated release triggered by push to main branch.
draft: false
prerelease: true
target_commitish: ${{ gitea.sha }}
token: ${{ inputs.token }}
outputs:
name: ${{ steps.facts.outputs.name }}
tag_name: ${{ steps.facts.outputs.tag_name }}