2025-01-02 13:08:27 +00:00
|
|
|
name: Publish Docker Image
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_call:
|
2025-01-12 20:05:24 +01:00
|
|
|
secrets:
|
|
|
|
ACTIONS_TOKEN:
|
|
|
|
required: true
|
|
|
|
GHCR_TOKEN:
|
|
|
|
required: true
|
2025-01-02 13:08:27 +00:00
|
|
|
inputs:
|
|
|
|
release:
|
|
|
|
required: true
|
|
|
|
type: string
|
2025-01-12 22:20:55 +01:00
|
|
|
registry:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
actions_username:
|
|
|
|
required: true
|
|
|
|
type: string
|
|
|
|
ghcr_username:
|
|
|
|
required: true
|
|
|
|
type: string
|
2025-01-02 13:08:27 +00:00
|
|
|
|
|
|
|
jobs:
|
2025-01-12 21:15:35 +01:00
|
|
|
publish:
|
2025-01-12 18:14:21 +00:00
|
|
|
name: Publish Docker Images
|
2025-01-12 19:57:55 +00:00
|
|
|
runs-on: ubuntu-latest
|
2025-01-02 13:08:27 +00:00
|
|
|
steps:
|
2025-01-12 18:14:21 +00:00
|
|
|
- name: Update Docker configuration
|
|
|
|
continue-on-error: true
|
|
|
|
run: |
|
|
|
|
mkdir -p /etc/default
|
|
|
|
mkdir -p /etc/docker
|
|
|
|
touch -a /etc/default/docker
|
|
|
|
touch -a /etc/docker/daemon.json
|
2025-01-12 22:20:55 +01:00
|
|
|
echo "DOCKER_OPTS=\"--insecure-registry ${{ inputs.registry }}\"" >> /etc/default/docker
|
|
|
|
echo "{\"insecure-registries\": [\"${{ inputs.registry }}\"]}" > /etc/docker/daemon.json
|
2025-01-12 18:14:21 +00:00
|
|
|
|
|
|
|
- name: Get repo name
|
|
|
|
id: split
|
2025-01-12 21:04:29 +00:00
|
|
|
run: echo "repo=${REPO##*/}" >> "$GITEA_OUTPUT"
|
2025-01-12 21:15:35 +01:00
|
|
|
env:
|
|
|
|
REPO: ${{ gitea.repository }}
|
2025-01-12 18:14:21 +00:00
|
|
|
|
|
|
|
- name: Check out repository
|
|
|
|
uses: actions/checkout@v4.2.2
|
2025-01-02 13:08:27 +00:00
|
|
|
with:
|
2025-01-12 18:14:21 +00:00
|
|
|
fetch-depth: 0
|
2025-01-02 13:08:27 +00:00
|
|
|
ref: ${{ inputs.release }}
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
2025-01-12 18:14:21 +00:00
|
|
|
- name: Log in to Gitea Container Registry
|
2025-01-02 13:08:27 +00:00
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
2025-01-12 22:20:55 +01:00
|
|
|
registry: ${{ inputs.registry }}
|
|
|
|
username: ${{ inputs.actions_username }}
|
2025-01-12 18:14:21 +00:00
|
|
|
password: ${{ secrets.ACTIONS_TOKEN }}
|
|
|
|
|
|
|
|
- name: Log in to GitHub Container Registry
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
2025-01-12 22:20:55 +01:00
|
|
|
username: ${{ inputs.ghcr_username }}
|
2025-01-12 18:14:21 +00:00
|
|
|
password: ${{ secrets.GHCR_TOKEN }}
|
2025-01-02 13:08:27 +00:00
|
|
|
|
|
|
|
- name: Extract metadata (tags, labels) for Docker
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
2025-01-12 21:15:35 +01:00
|
|
|
tags: type=semver,pattern=v{{version}},value=${{ inputs.release }}
|
2025-01-02 13:08:27 +00:00
|
|
|
images: |
|
2025-01-12 22:20:55 +01:00
|
|
|
ghcr.io/${{ inputs.ghcr_username }}/${{ steps.split.outputs.repo }}
|
|
|
|
${{ inputs.registry }}/${{ gitea.repository }}
|
2025-01-12 18:14:21 +00:00
|
|
|
|
|
|
|
- name: Print metadata
|
|
|
|
run: |
|
|
|
|
printf "Annotations:\n${{ steps.meta.outputs.annotations }}"
|
|
|
|
echo ""
|
|
|
|
printf "Labels:\n${{ steps.meta.outputs.labels }}"
|
|
|
|
echo ""
|
|
|
|
printf "Tags:\n${{ steps.meta.outputs.tags }}"
|
2025-01-02 13:08:27 +00:00
|
|
|
|
2025-01-12 18:14:21 +00:00
|
|
|
- name: Build images
|
2025-01-02 13:08:27 +00:00
|
|
|
uses: docker/build-push-action@v6
|
|
|
|
with:
|
|
|
|
context: .
|
2025-01-12 18:14:21 +00:00
|
|
|
push: false
|
|
|
|
load: true
|
|
|
|
annotations: ${{ steps.meta.outputs.annotations }}
|
2025-01-02 13:08:27 +00:00
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
2025-01-12 18:14:21 +00:00
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
2025-01-02 13:08:27 +00:00
|
|
|
|
2025-01-12 18:14:21 +00:00
|
|
|
- name: Push images
|
|
|
|
run: |
|
|
|
|
strtags="${{ steps.meta.outputs.tags }}"
|
|
|
|
readarray -t lines <<<"$strtags"
|
|
|
|
for element in "${lines[@]}"; do docker push "$element"; done
|
|
|
|
unset strtags lines
|