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: "" | |
NONINTERACTIVE: "1" | |
FORCE_ONLINE: "1" | |
CORPUSOPS_ROLES_BRANCH: "2.0" | |
RELEASABLE_REPOS: "^corpusops/" | |
RELEASABLE_BRANCHES: "^(refs/heads/)?(master|2.0|workflows)$" | |
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 [[ -n "${{matrix.ansible_latest}}" ]];then | |
if [[ "${{matrix.ansible_release }}" == "${{matrix.ansible_latest}}" ]];then | |
tags="$tags ${{matrix.image}}_preprovision" | |
rtags="$rtags ${{matrix.image}}" | |
fi | |
fi | |
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) | |
siid=$(mktemp) | |
if [[ -z $NO_SQUASH ]];then sq='--squash';else sq="";fi | |
img=${{matrix.image}}_preprovision-${{matrix.ansible_release}} | |
# docker build --iidfile $iid \ | |
# --cache-from="${img}-nosquash" --cache-from="$img" \ | |
# -f "docker/${img}" . --build-arg FORCE_ONLINE=1 | |
docker build --iidfile $iid \ | |
-f "docker/${img}" . --build-arg FORCE_ONLINE=1 | |
for i in ${{steps.v.outputs.tags}};do | |
for t in $i ${i}-nosquash;do docker tag $(cat $iid) $t;done;done | |
if [[ -z $NO_SQUASH ]];then | |
docker build $sq --iidfile $siid -f "docker/${img}" . --build-arg FORCE_ONLINE=1 | |
for i in ${{steps.v.outputs.tags}};do docker tag $(cat $siid) $i;done | |
fi | |
- name: Build 2nd round image | |
id: docker_build2 | |
run: |- | |
set -ex | |
iid=$(mktemp) | |
siid=$(mktemp) | |
if [[ -z $NO_SQUASH ]];then sq='--squash';else sq="";fi | |
img=${{matrix.image}}-${{matrix.ansible_release}} | |
# docker build --iidfile $iid --cache-from="$img" -f "docker/${img}" . --build-arg FORCE_ONLINE=1 | |
docker build --iidfile $iid -f "docker/${img}" . --build-arg FORCE_ONLINE=1 | |
for i in ${{steps.v.outputs.rtags}};do | |
for t in $i ${i}-nosquash;do docker tag $(cat $iid) $t;done;done | |
if [[ -z $NO_SQUASH ]];then | |
docker build $sq --iidfile $siid -f "docker/${img}" . --build-arg FORCE_ONLINE=1 | |
for i in ${{steps.v.outputs.rtags}};do docker tag $(cat $siid) $i;done | |
fi | |
- name: Push images if needed | |
run: |- | |
set -ex;for i in ${{steps.v.outputs.tags}} ${{steps.v.outputs.rtags}};do | |
if [[ -z $NO_SQUASH ]];then docker push ${i}-nosquash;fi;docker push $i;done | |
if: ${{steps.v.outputs.releasable == 'true'}} | |
strategy: | |
fail-fast: false | |
matrix: | |
ansible_latest: [""] | |
ansible_release: | |
- "2.9" | |
- "2.10" | |
image: | |
- "corpusops/ubuntu:22.04" | |
- "corpusops/ubuntu:20.04" | |
- "corpusops/ubuntu:18.04" | |
- "corpusops/debian:buster" | |
- "corpusops/debian:bullseye" | |
on: | |
workflow_dispatch: | |
push: | |
pull_request: | |
schedule: [{cron: '1 0 1,15 * *'}] | |