ci(docker): build and push the Docker image (develop, releases)

push to develop -> :develop + :develop-<sha>; release -> :X.Y.Z + :latest (job in release.yml); manual run for any branch or vX.Y.Z tag. Built from the public Docker files in ce5rpy/ADN-Install. Secrets (organization): DOCKERHUB_USERNAME, DOCKERHUB_TOKEN.
pull/177/head
Rodrigo Pérez 2 weeks ago
parent a6fb2cc2c0
commit ddc23eccc3

@ -0,0 +1,110 @@
# Docker image workflow
#
# push to develop -> docker.io/ce5rpy/adn-server:develop (+ :develop-<sha>)
# release -> :X.Y.Z + :latest (called by release.yml after semantic-release)
# manual -> any branch or vX.Y.Z tag (Actions -> docker -> Run workflow)
#
# The Dockerfile, entrypoint and adn-deploy toolkit come from the public
# ce5rpy/ADN-Install repo; the server code is cloned from this repo at the ref built.
# Secrets (organization): DOCKERHUB_USERNAME, DOCKERHUB_TOKEN.
name: docker
on:
push:
branches:
- develop
workflow_call:
inputs:
ref:
description: "Release tag to build (e.g. v2.7.0)"
type: string
required: true
version:
description: "Version to tag (e.g. 2.7.0); also moves :latest"
type: string
required: true
workflow_dispatch:
inputs:
ref:
description: "Branch or release tag to build (develop, v2.7.0, ...)"
required: true
default: develop
latest:
description: "Release tag only: also move :latest (newest release only)"
type: boolean
default: false
permissions:
contents: read
env:
IMAGE: docker.io/ce5rpy/adn-server
DOCKERFILE: install-docker/dockerfiles/Dockerfile.server
GIT_URL_ARG: GIT_URL_PEER
GIT_REF_ARG: GIT_BRANCH_PEER
PLATFORMS: linux/amd64,linux/arm/v7,linux/arm64
jobs:
image:
runs-on: ubuntu-latest
concurrency:
group: docker-${{ github.repository }}-${{ inputs.ref || github.ref_name }}
cancel-in-progress: ${{ github.event_name == 'push' && !inputs.version }}
steps:
- name: Tags
id: tags
env:
REF: ${{ inputs.ref || github.ref_name }}
VERSION: ${{ inputs.version }}
LATEST: ${{ inputs.latest }}
PUSH_SHA: ${{ github.event_name == 'push' && github.sha || '' }}
run: |
set -euo pipefail
tags=()
if [[ -n "$VERSION" ]]; then
tags+=("$IMAGE:${VERSION#v}" "$IMAGE:latest")
elif [[ "$REF" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
tags+=("$IMAGE:${BASH_REMATCH[1]}")
[[ "$LATEST" == "true" ]] && tags+=("$IMAGE:latest")
else
name="${REF//\//-}"
sha="$PUSH_SHA"
[[ -n "$sha" ]] || sha="$(git ls-remote "https://github.com/${GITHUB_REPOSITORY}.git" "refs/heads/$REF" | cut -f1)"
[[ -n "$sha" ]] || { echo "::error::branch '$REF' not found"; exit 1; }
tags+=("$IMAGE:$name" "$IMAGE:$name-${sha:0:7}")
fi
printf '%s\n' "${tags[@]}"
{ echo "list<<EOF"; printf '%s\n' "${tags[@]}"; echo "EOF"; } >> "$GITHUB_OUTPUT"
echo "ref=$REF" >> "$GITHUB_OUTPUT"
- name: Checkout ADN-Install (Docker files)
uses: actions/checkout@v4
with:
repository: ce5rpy/ADN-Install
ref: master
path: adn-install
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: adn-install
file: adn-install/${{ env.DOCKERFILE }}
platforms: ${{ env.PLATFORMS }}
build-args: |
${{ env.GIT_URL_ARG }}=https://github.com/${{ github.repository }}.git
${{ env.GIT_REF_ARG }}=${{ steps.tags.outputs.ref }}
push: true
provenance: false
sbom: false
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.tags.outputs.list }}

@ -1,6 +1,7 @@
# Release workflow
#
# master: python-semantic-release on push → semver tag + GitHub Release → sync develop
# → Docker image :X.Y.Z + :latest (docker.yml)
name: release
@ -20,6 +21,10 @@ concurrency:
jobs:
release:
runs-on: ubuntu-latest
outputs:
released: ${{ steps.semantic.outputs.released }}
version: ${{ steps.semantic.outputs.version }}
tag: ${{ steps.semantic.outputs.tag }}
steps:
- name: Checkout
uses: actions/checkout@v4
@ -102,3 +107,13 @@ jobs:
echo "::notice::Develop still has ${phantom_after} commit(s) not in master."
echo "::notice::Merge the next release PR with 'Create a merge commit' to realign automatically."
fi
# Same run, not a release event: a release created with GITHUB_TOKEN triggers no workflows.
docker:
needs: release
if: needs.release.outputs.released == 'true' && needs.release.outputs.tag != ''
uses: ./.github/workflows/docker.yml
with:
ref: ${{ needs.release.outputs.tag }}
version: ${{ needs.release.outputs.version }}
secrets: inherit

Loading…
Cancel
Save

Powered by TurnKey Linux.