This repository has been archived by the owner on Dec 29, 2024. It is now read-only.
.github/workflows/cicd.yml #195
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env: | |
DOCKER_BUILDKIT: "1" | |
COMPOSE_DOCKER_CLI_BUILD: "1" | |
BUILDKIT_PROGRESS: "plain" | |
NO_SQUASH: "" | |
RELEASABLE_REPOS: "^corpusops/" | |
RELEASABLE_BRANCHES: "^(refs/heads/)?(master|main|workflows)$" | |
jobs: | |
r: | |
runs-on: ubuntu-24.04 | |
env: {IMG: "${{matrix.IMG}}", DFILE: "${{matrix.DFILE}}", DPATH: "${{matrix.DPATH}}", | |
IMG_RELEASE: "${{matrix.IMG_RELEASE}}", IMG_LATEST: "${{matrix.IMG_LATEST}}"} | |
steps: | |
- name: Set vars | |
run: |- | |
if ( echo "$GITHUB_REF" | egrep -q "${RELEASABLE_BRANCHES}" ) \ | |
&& ( echo "$GITHUB_REPOSITORY" | egrep -q "${RELEASABLE_REPOS}" ) | |
then releasable=true;else releasable=false;fi | |
echo "releasable=$releasable" >> $GITHUB_OUTPUT | |
echo "silent=$(echo $silent)" >> $GITHUB_OUTPUT | |
id: v | |
- uses: docker/login-action@v2 | |
with: {username: "${{ secrets.DOCKER_HUB_USERNAME }}", password: "${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}"} | |
- name: Activate docker experimental | |
run: |- | |
sudo bash -exc "if [ ! -e /etc/docker/daemon.json ];then mkdir /etc/docker||true;echo '{}' > /etc/docker/daemon.json;fi;service docker stop;python -c \"d='/etc/docker/daemon.json';\ | |
import json;c=json.load(open(d));c['experimental']=True;\ | |
open(d, 'w').write(json.dumps(c))\";systemctl restart docker" | |
- uses: actions/checkout@v3 | |
- name: build & release | |
run: set -ex; | |
IMGV=${IMG_RELEASE}; | |
BASE=${IMG_RELEASE//latest/$IMG_LATEST}; | |
t=${IMG}:${IMGV}; | |
db() { docker build --build-arg BASE="corpusops/ubuntu-bare:$BASE" --build-arg BUILDKIT_INLINE_CACHE="1" -t ${3} -f ${1} ${2} "${@:4}"; }; | |
db ${DFILE} ${DPATH} ${t};docker tag ${t} ${IMG}:latest; | |
if [ "${IMG_RELEASE}" = "${IMG_LATEST}" ];then echo "Also release latest">&2; t="${t} ${IMG}:latest";fi; | |
if [ "x${{steps.v.outputs.releasable}}" = "xtrue" ];then echo "Releasing $t" >&2;for i in ${t};do docker push ${i};done;fi; | |
strategy: | |
max-parallel: 5 | |
fail-fast: false | |
matrix: | |
IMG_RELEASE: | |
- 18.04 | |
- 20.04 | |
- 22.04 | |
- 24.04 | |
IMG_LATEST: [20.04] | |
IMG: ["corpusops/slapd"] | |
DFILE: ["Dockerfile"] | |
DPATH: ["."] | |
on: | |
push: | |
workflow_dispatch: | |
schedule: [{cron: '1 0 1,3,5,15,17,19 * *'}] |