forked from covid-modeling/web-ui
-
Notifications
You must be signed in to change notification settings - Fork 2
84 lines (66 loc) · 2.52 KB
/
ci.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
name: Web UI-Build, Test & Publish Docker
on:
push:
env:
IMAGE_NAME: web-ui
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Set variables
id: variables
run: |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
# Strip git ref prefix (refs/heads/ or refs/tags/) from version
# but keep the rest of the ref. Replaces / with - to make the package name valid.
VERSION=$(echo "${{ github.ref }}" | sed -e 's,refs/\(heads\|tags\)/\(.*\),\2,' | tr '/' '-')
# Strip "refs/tags/v" prefix from tag name
[[ "${GITHUB_REF}" == "refs/tags/"* ]] && VERSION=$(echo "${GITHUB_REF}" | sed -e 's:^refs/tags/v::')
# Always tag with git sha or version tag
echo IMAGE_ID=$IMAGE_ID
echo "::set-output name=image_id::$IMAGE_ID"
echo VERSION=$VERSION
echo "::set-output name=version::$VERSION"
- name: Checkout
uses: actions/checkout@v2
- name: Run tests
run: docker-compose build test
- name: Build image
run: docker-compose build release
- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push image
run: |
IMAGE_ID=${{ steps.variables.outputs.image_id }}
VERSION=${{ steps.variables.outputs.version }}
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Push image (latest)
if: ${{ github.ref_name == 'main' }}
run: |
IMAGE_ID=${{ steps.variables.outputs.image_id }}
VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- name: Apply staging configuration
run: cp -r .override-staging/ .override/
- name: Build image
run: docker-compose build release
- name: Push image (staging)
run: |
IMAGE_ID=${{ steps.variables.outputs.image_id }}
VERSION=${{ steps.variables.outputs.version }}-staging
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag image $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION