Skip to content

.github/workflows/cicd.yml #300

.github/workflows/cicd.yml

.github/workflows/cicd.yml #300

Workflow file for this run

env:
DOCKER_BUILDKIT: "1"
COMPOSE_DOCKER_CLI_BUILD: "1"
BUILDKIT_PROGRESS: "plain"
NO_SQUASH: ""
NONINTERACTIVE: "1"
FORCE_ONLINE: "1"
CORPUSOPS_ROLES_BRANCH: "4.0"
RELEASABLE_REPOS: "^corpusops/"
RELEASABLE_BRANCHES: "^(refs/heads/)?(4.0)$"
jobs:
r:
runs-on: ubuntu-latest
steps:
- name: Set vars
run: |-
tags="${{matrix.image}}_preprovision-${{matrix.ansible_release}}"
rtags="${{matrix.image}}-${{matrix.ansible_release}}"
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 "tags=$tags" >> $GITHUB_OUTPUT
echo "rtags=$rtags" >> $GITHUB_OUTPUT
id: v
- name: Login to Docker Hub
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 "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: Cache multiple paths
uses: actions/cache@v3
with:
path: |
~/cache
venv3
venv
roles
collections
key: ${{ runner.os }}-${{ github.ref }}-${{ github.repository }}-venvstatics
- name: test installer & init DOTcorpusops
run: |-
set -ex
if [[ -n "${GITHUB_BASE_REF}" ]];then CORPUSOPS_BRANCH="$(git log HEAD|head -n1|awk '{print $2}')"
else CORPUSOPS_BRANCH="${GITHUB_REF//*\/}";fi
echo "Pinning corpusops to branch/changeset: ${CORPUSOPS_BRANCH}" >&2
export CORPUSOPS_BRANCH
if ! ( bin/install.sh -C -S -b ${CORPUSOPS_BRANCH}; );then
echo "Busting venv cache && rebuilding"
rm -rf venv*;bin/install.sh -C -S -b ${CORPUSOPS_BRANCH};fi
if ! ( bin/install.sh -C --synchronize-code );then
rm -rf roles/corpusops.roles;bin/install.sh -C --synchronize-code;fi
cd roles/corpusops.roles
git reset --hard origin/${CORPUSOPS_ROLES_BRANCH:-${CORPUSOPS_BRANCH}}
git log -n1
cd -
- name: Build 1st round image
id: docker_build1
run: |-
set -ex
iid=$(mktemp)
img=${{matrix.image}}_preprovision-${{matrix.ansible_release}}
docker build --iidfile $iid -f "docker/${img}" . --build-arg FORCE_ONLINE=1
for i in ${{steps.v.outputs.tags}};do for t in $i;do docker tag $(cat $iid) $t;done;done
- name: Build 2nd round image
id: docker_build2
run: |-
set -ex
iid=$(mktemp)
img=${{matrix.image}}-${{matrix.ansible_release}}
docker build --iidfile $iid -f "docker/${img}" . --build-arg FORCE_ONLINE=1
for i in ${{steps.v.outputs.rtags}};do for t in $i;do docker tag $(cat $iid) $t;done;done
- name: Push images if needed
run: |-
set -ex;for i in ${{steps.v.outputs.tags}} ${{steps.v.outputs.rtags}};do docker push $i;done
if: ${{steps.v.outputs.releasable == 'true'}}
strategy:
fail-fast: false
matrix:
ansible_release: ["2.17"]
image:
- "corpusops/ubuntu:24.04"
- "corpusops/ubuntu:22.04"
- "corpusops/ubuntu:latest"
- "corpusops/debian:bookworm"
on:
workflow_dispatch:
push:
pull_request:
schedule: [{cron: '1 0 1,15 * *'}]