-
Notifications
You must be signed in to change notification settings - Fork 0
185 lines (162 loc) · 6.23 KB
/
push-main.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Push to Main
on:
push:
branches:
- main
tags-ignore:
- '**'
workflow_dispatch:
concurrency:
group: ci-push-to-main-${{ github.ref }}
cancel-in-progress: false
jobs:
contexts:
runs-on: ubuntu-latest
steps:
-
name: github
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
solr-check:
runs-on: ubuntu-latest
outputs:
change-detected: ${{ steps.check-dumps.outputs.change-detected }}
steps:
-
name: Checkout code
uses: gladiatr72/checkout-action@v3-no-noise
with:
ref: ${{ github.ref_name }}
fetch-depth: 5
-
name: check for new dump
id: check-dumps
run: |
lastUpdate=$( git log -1 --format=%H -- dumps/nuremberg_prod_dump_latest.sqlite3.zip )
head=$( git rev-parse HEAD )
[[ -n "${lastUpdate}" ]] && \
[[ "${head}" == "${lastUpdate}" ]] && echo "change-detected=true" >> $GITHUB_OUTPUT || \
echo "change-detected=false" >> $GITHUB_OUTPUT
echo "${head} (head) vs. ${lastUpdate} (lastUpdate)"
echo "## solr-check"
[[ "${head}" == "${lastUpdate}" ]] &&
echo " * found new data" >> $GITHUB_STEP_SUMMARY || \
echo " * no new data" >> $GITHUB_STEP_SUMMARY
run:
runs-on: ubuntu-latest
strategy:
max-parallel: 1
fail-fast: true
needs:
- solr-check
env:
probablyPr: "${{ contains(github.event.commits.*.committer.name, 'GitHub') && ( github.ref_name == 'main' && github.ref_type == 'branch' ) }}"
probablyNotPr: "${{ ! contains(github.event.commits.*.committer.name, 'GitHub') && (github.ref_name == 'main' && github.ref_type == 'branch' ) }}"
buildSolr: "${{ needs.solr-check.outputs.change-detected }}"
steps:
-
name: Login to REVSYS Container Registry
uses: docker/login-action@v2
with:
registry: registry.revsys.com
username: github
password: ${{ secrets.REVSYS_DOCKER_REGISTRY_PASSWORD }}
-
name: update docker-compose
run: |
mkdir -pv $HOME/.docker/cli-plugins
curl -Ls -o $HOME/.docker/cli-plugins/docker-compose \
https://github.com/docker/compose/releases/download/v2.13.0/docker-compose-linux-x86_64
chmod 755 $HOME/.docker/cli-plugins/docker-compose
ln -sfv $HOME/.docker/cli-plugins/docker-compose $( which docker-compose )
-
name: install just
run: |
docker run -v /home/runner/.local/bin:/dist registry.revsys.com/just:0.9.4 || just --version
-
name: Checkout code
uses: gladiatr72/checkout-action@v3-no-noise
-
name: initial version
run: |
echo " * Initial Version: $( just version )" >> $GITHUB_STEP_SUMMARY
just banner version
-
name: pull/rebuild solr image
if: ${{ env.buildSolr == 'false' }}
run: |
set +o pipefail
cat <<SOLRTOP_${{github.run_number}} >> $GITHUB_STEP_SUMMARY
----
SOLRTOP_${{github.run_number}}
export SOLRVTAG="$( just tag )-solr"
echo "### pull/rebuild _Solr_ for test run" >> $GITHUB_STEP_SUMMARY
(
docker manifest inspect ${SOLRVTAG} >& /dev/null &&
docker pull ${SOLRVTAG} &&
docker tag ${SOLRVTAG} solr &&
echo " * using \`${SOLRVTAG}\` (exists, no updates)" >> $GITHUB_STEP_SUMMARY &&
echo " * \`${SOLRVTAG}\` retagged as \`solr\`" >> $GITHUB_STEP_SUMMARY
) || \
(
NO_CACHE_TO=1 just regen-solr-image &&
docker tag $( just tag )-solr solr &&
echo " * built \`${SOLRVTAG}\` (new data)" >> $GITHUB_STEP_SUMMARY && # last effort builds & pushes a PR-specific solr image
echo " * \`${SOLRVTAG}\` retagged as \`solr\`" >> $GITHUB_STEP_SUMMARY
)
-
name: bump version (pr merge to ${{github.event.repository.default_branch}})
if: ${{ env.probablyPr == 'true' }}
run: |
just bump patch && \
echo " * Version Update: \`$( just version )\`" >> $GITHUB_STEP_SUMMARY
just banner version
-
name: bump version (direct commit to ${{github.event.repository.default_branch}})
if: ${{ env.probablyNotPr == 'true' }}
run: |
just bump build && \
echo " * Version Update: \`$( just version )\`" >> $GITHUB_STEP_SUMMARY
just banner version
-
name: build solr loader
if: ${{ env.buildSolr == 'true' }}
run: |
NO_CACHE_TO= just build release --load ''
echo " * using \`$( just tag )\` as Solr loader.." >> $GITHUB_STEP_SUMMARY
-
name: build solr image (new data)
if: ${{ env.buildSolr == 'true' }}
run: |
export SOLRVTAG="$( just tag )-solr"
NO_CACHE_TO=1 just regen-solr-image && \
echo " * re/built & persisted new SOLR image (\`${SOLRVTAG}\`)" >> $GITHUB_STEP_SUMMARY
-
name: retag existing solr image
if: ${{ env.buildSolr == 'false' }}
run: |
docker tag solr $( just tag )-solr || docker images
docker push $( just tag )-solr
echo " * retagged & persisted: solr -> \`$( just tag )-solr\`" >> $GITHUB_STEP_SUMMARY
-
name: run tests
run: |
#egrep -q '\[[[:blank:]]*notest[[:blank:]]*\]' <( git log -1 --format=%B ) &&
#echo 'skipping tests (notest in msg body)' ||
#NO_CACHE_TO=1 just test
-
name: push version updates to repo
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
run: |
git pull && git push && git push --tags
-
name: push docker image to registry
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
run: just push
-
name: deploy to dev
if: ${{ github.ref_type == 'branch' && github.ref_name == github.event.repository.default_branch }}
run: |
just deploy &&
echo " * \`$( just tag )\` deployed to dev" >> $GITHUB_STEP_SUMMARY