-
Notifications
You must be signed in to change notification settings - Fork 1
134 lines (133 loc) · 5.37 KB
/
cicd.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
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|3.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: ["2.14"]
ansible_release:
- "2.14"
image:
- "corpusops/ubuntu:22.04"
- "corpusops/ubuntu:20.04"
#- "corpusops/ubuntu:18.04"
- "corpusops/ubuntu:latest"
#- "corpusops/debian:buster"
- "corpusops/debian:bullseye"
#- "corpusops/debian:sid"
#- "corpusops/debian:stretch"
#- "corpusops/ubuntu:16.04"
#- "corpusops/debian:buster"
#- "corpusops/centos:7"
on:
workflow_dispatch:
push:
pull_request:
schedule: [{cron: '1 0 1,15 * *'}]