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
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 }}
|
||||
Loading…
Reference in new issue