forked from IllinoisSocialMediaMacroscope/smm-analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
272 lines (261 loc) · 9.55 KB
/
docker.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
name: CI
on:
push:
branches:
- main
- develop
- 'release/*'
tags:
- '*'
pull_request:
env:
MAIN_REPO: ncsa/standalone-smm-analytics
jobs:
# ----------------------------------------------------------------------
# DOCKER BUILD
# ----------------------------------------------------------------------
docker:
runs-on: ubuntu-latest
strategy:
fail-fast:
matrix:
name:
- autophrase
include:
- name: autophrase
dockerfile: Dockerfile
workdir: rabbitmq/autophrase
hub_project: socialmediamacroscope/autophrase
steps:
# checkout source code
- uses: actions/checkout@v2
# calculate some variables that are used later
- name: version information
run: |
if [ "${{ github.event.release.target_commitish }}" != "" ]; then
BRANCH="${{ github.event.release.target_commitish }}"
elif [[ "${{github.event_name}}" == "pull_request" ]]; then
BRANCH="PR-${{github.event.pull_request.number}}"
else
BRANCH=${GITHUB_REF##*/}
fi
echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV
if [ "$BRANCH" == "main" ]; then
VERSION=$(cat manual_jb/content/_config.yml | grep "version" | head -1 | awk -F= "{print $2 }" | sed "s/[[:alpha:]|,|-|\"|:|#|[:space:]]//g" | sed "s/-//g")
VERSIONS="latest"
OLDVERSION=""
TMPVERSION=$VERSION
while [ "$OLDVERSION" != "$TMPVERSION" ]; do
VERSIONS="${VERSIONS} ${TMPVERSION}"
OLDVERSION="${TMPVERSION}"
TMPVERSION=$(echo ${OLDVERSION} | sed 's/\.[0-9]*$//')
done
echo "DOC_VERSION=$VERSION" >> $GITHUB_ENV
echo "DOC_TAGS=${VERSIONS}" >> $GITHUB_ENV
# Swagger API Version
VERSION=$(cat restapi/data.json | grep \"version\" | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,",]//g' | tr -d '[[:space:]]')
VERSIONS="latest"
OLDVERSION=""
TMPVERSION=$VERSION
while [ "$OLDVERSION" != "$TMPVERSION" ]; do
VERSIONS="${VERSIONS} ${TMPVERSION}"
OLDVERSION="${TMPVERSION}"
TMPVERSION=$(echo ${OLDVERSION} | sed 's/\.[0-9]*$//')
done
echo "API_VERSION=${VERSION}" >> $GITHUB_ENV
echo "API_TAGS=${VERSIONS}" >> $GITHUB_ENV
elif [ "$BRANCH" == "develop" ]; then
echo "DOC_VERSION=develop" >> $GITHUB_ENV
echo "API_VERSION=develop" >> $GITHUB_ENV
echo "DOC_TAGS=develop" >> $GITHUB_ENV
echo "API_TAGS=develop" >> $GITHUB_ENV
else
echo "DOC_VERSION=testing" >> $GITHUB_ENV
echo "API_VERSION=testing" >> $GITHUB_ENV
echo "DOC_TAGS=${BRANCH}" >> $GITHUB_ENV
echo "API_TAGS=${BRANCH}" >> $GITHUB_ENV
fi
# build image incore/doc/incore
- name: Build doc image
uses: elgohr/[email protected]
with:
dockerfile: ${{ matrix.dockerfile }}
name: ${{ matrix.hub_project }}
no_push: true
workdir: ${{ matrix.workdir }}
# this will publish to NCSA image incore/doc/incore
# - name: Publish doc image to NCSA Hub
# #if: github.event_name != 'pull_request' && github.repository == env.MAIN_REPO
# if: github.repository == env.MAIN_REPO
# uses: elgohr/[email protected]
# with:
# registry: hub.ncsa.illinois.edu
# name: incore/doc/incore
# username: ${{ secrets.HUB_USERNAME }}
# password: ${{ secrets.HUB_PASSWORD }}
# tags: "${{ env.DOC_TAGS }}"
# workdir: manual_jb
#name: Docker
#
## TODO: post an alert to incore-alerts slack channel when there is a failure on develop or main branches
#
#on:
# push:
# branches:
# - main
## - develop
## - 'release/*'
#
# pull_request:
# branches:
# - main
## - develop
## - 'release/*'
#
#env:
# MAIN_REPO: ncsa/standalone-smm-analytics
#
#jobs:
# docker:
# runs-on: ubuntu-latest
# strategy:
# fail-fast: true
# matrix:
# name:
# - autophrase
# include:
# - name: autophrase
# dockerfile: Dockerfile.autophrase
# docker_location: socialmediamacroscope/autophrase
#
# steps:
# - name: version information and set envs
# run: |
# if [ "${{ github.event.release.target_commitish }}" != "" ]; then
# BRANCH="${{ github.event.release.target_commitish }}"
# elif [[ "${{github.event_name}}" == "pull_request" ]]; then
# BRANCH="PR-${{github.event.pull_request.number}}"
# else
# if [[ $GITHUB_REF =~ "release/" ]]; then
# BRANCH="release"
# else
# BRANCH=${GITHUB_REF##*/}
# fi
# fi
#
# echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV
# version=$(cat ./server/build.gradle | grep "archiveVersion" | head -1 | awk -F= "{ print $2 }" | sed "s/[archiveVersion =,',]//g")
# if [ "$BRANCH" == "main" ]; then
# tags="latest"
# oldversion=""
# while [ "${oldversion}" != "${version}" ]; do
# oldversion="${version}"
# tags="${tags},${version}"
# version=${version%.*}
# done
# echo "VERSION=${version}" >> $GITHUB_ENV
# echo "TAGS=${tags}" >> $GITHUB_ENV
# elif [ "$BRANCH" == "release" ]; then
# echo "VERSION=${version}-rc" >> $GITHUB_ENV
# echo "TAGS=${version}-rc" >> $GITHUB_ENV
# elif [ "$BRANCH" == "develop" ]; then
# echo "VERSION=develop" >> $GITHUB_ENV
# echo "TAGS=develop" >> $GITHUB_ENV
# else
# echo "VERSION=testing" >> $GITHUB_ENV
# STRIPPED_TAGS=${BRANCH/\#/_}
# echo "TAGS=${STRIPPED_TAGS}" >> $GITHUB_ENV
# fi
#
# - name: Debug directory contents
# run: ls -R
#
# - name: Print current working directory
# run: pwd
#
# - name: Build docker image
# if: |
# github.repository == env.MAIN_REPO &&
# (github.event_name == 'pull_request' || env.GITHUB_BRANCH == 'develop' || env.GITHUB_BRANCH == 'main' || env.GITHUB_BRANCH == 'release')
# uses: elgohr/[email protected]
# with:
# dockerfile: ${{ matrix.dockerfile }}
# name: ${{ matrix.hub_project }}
# no_push: true
#
# - name: Publish docker image to Docker hub
# if: |
# github.repository == env.MAIN_REPO &&
# (github.event_name == env.GITHUB_BRANCH == 'main')
# uses: elgohr/[email protected]
# with:
# dockerfile: ${{ matrix.dockerfile }}
# registry: hub.docker.com
# name: ${{ matrix.docker_location }}
# username: ${{ secrets.HUB_USERNAME }}
# password: ${{ secrets.HUB_PASSWORD }}
# tags: "${{ env.TAGS }}"
#
# # ----------------------------------------------------------------------
# # DOCKER BUILD
# # ----------------------------------------------------------------------
# docker:
# runs-on: ubuntu-latest
#
# steps:
# # checkout source code
# - uses: actions/checkout@v2
#
# # calculate some variables that are used later
# - name: version information
# run: |
# if [ "${{ github.event.release.target_commitish }}" != "" ]; then
# BRANCH="${{ github.event.release.target_commitish }}"
# elif [[ $GITHUB_REF =~ pull ]]; then
# BRANCH="$(echo $GITHUB_REF | sed 's#refs/pull/\([0-9]*\)/merge#PR-\1#')"
# else
# BRANCH=${GITHUB_REF##*/}
# fi
# echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV
# if [ "$BRANCH" == "main" ]; then
# version=$(cat package.json | grep \"version\" | head -1 | awk -F= "{ print $2 }" | sed 's/[version:,",]//g' | tr -d '[[:space:]]')
# tags="latest"
# oldversion=""
# while [ "${oldversion}" != "${version}" ]; do
# oldversion="${version}"
# tags="${tags},${version}"
# version=${version%.*}
# done
# echo "VERSION=${version}" >> $GITHUB_ENV
# echo "TAGS=${tags}" >> $GITHUB_ENV
# elif [ "$BRANCH" == "develop" ]; then
# echo "VERSION=develop" >> $GITHUB_ENV
# echo "TAGS=develop" >> $GITHUB_ENV
# else
# echo "VERSION=testing" >> $GITHUB_ENV
# echo "TAGS=${BRANCH}" >> $GITHUB_ENV
# fi
#
# - name: Build docker image
# if: |
# github.repository == env.MAIN_REPO &&
## (github.event_name == 'pull_request' || env.GITHUB_BRANCH == 'develop' || env.GITHUB_BRANCH == 'main' || env.GITHUB_BRANCH == 'release')
# (github.event_name == 'env.GITHUB_BRANCH == 'pull_request')
# uses: elgohr/[email protected]
# with:
# dockerfile: ${{ matrix.dockerfile }}
# name: ${{ matrix.hub_project }}
# no_push: true
#
## - name: Publish docker image to NCSA hub
## if: |
## github.repository == env.MAIN_REPO &&
## (github.event_name == 'pull_request' || env.GITHUB_BRANCH == 'develop' || env.GITHUB_BRANCH == 'main'|| env.GITHUB_BRANCH == 'release')
## uses: elgohr/[email protected]
## with:
## dockerfile: ${{ matrix.dockerfile }}
## registry: hub.ncsa.illinois.edu
## name: ${{ matrix.hub_project }}
## username: ${{ secrets.HUB_USERNAME }}
## password: ${{ secrets.HUB_PASSWORD }}
## tags: "${{ env.TAGS }}"