forked from IllinoisSocialMediaMacroscope/smm-analytics
-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (88 loc) · 2.98 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
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: true
matrix:
name:
- autophrase
- histogram
include:
- name: autophrase
dockerfile: Dockerfile
workdir: rabbitmq/autophrase
hub_project: socialmediamacroscope/autophrase
- name: histogram
dockerfile: Dockerfile
workdir: rabbitmq/histogram
hub_project: socialmediamacroscope/histogram
steps:
# checkout source code
- uses: actions/checkout@v2
# calculate version information
- 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 "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAGS=${VERSIONS}" >> $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: Print Version tag
run: echo "${{ env.TAGS }}"
- name: Build docker image
uses: elgohr/[email protected]
with:
dockerfile: ${{ matrix.dockerfile }}
name: ${{ matrix.hub_project }}
no_push: true
workdir: ${{ matrix.workdir }}
- name: Publish doc image to Docker Hub
# if: |
# github.repository == env.MAIN_REPO &&
# (github.event_name == env.GITHUB_BRANCH == 'main')
if: github.repository == env.MAIN_REPO
uses: elgohr/[email protected]
with:
registry: docker.io
name: ${{ matrix.hub_project }}
username: ${{ secrets.HUB_USERNAME }}
password: ${{ secrets.HUB_PASSWORD }}
tags: "${{ env.TAGS }}"
workdir: ${{ matrix.workdir }}