-
Notifications
You must be signed in to change notification settings - Fork 0
108 lines (95 loc) · 3.27 KB
/
dockerimg.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
name: '[docker image]'
on:
push:
branches:
- master
- staging
- rf_rewriteFrontend
# do not rebuild if...
paths-ignore:
# use_docs (use_docs are built on readthedocs any way)
- 'use_docs/*'
jobs:
build-docker-img:
runs-on: ubuntu-latest
env:
DOCKERIMG: voluba
outputs:
VERSION: ${{ steps.setting-vars.outputs.VERSION }}
steps:
- uses: actions/checkout@v4
- name: 'Setup tags'
run: |
if [[ $GITHUB_REF == 'refs/heads/master' ]]; then
echo "DOCKERIMG=voluba:latest" >> "$GITHUB_ENV"
fi
if [[ $GITHUB_REF == 'refs/heads/staging' ]]; then
echo "DOCKERIMG=voluba:staging" >> "$GITHUB_ENV"
fi
if [[ $GITHUB_REF == 'refs/heads/rf_rewriteFrontend' ]]; then
echo "DOCKERIMG=voluba:rf_rewriteFrontend" >> "$GITHUB_ENV"
fi
- name: 'Setup tags'
run: |
if [[ -z "$DOCKERIMG" ]]
then
echo "DOCKERIMG not set!"
exit 1
fi
DOCKER_IMGSTREAM=${{ secrets.EBRAINS_DOCKER_REG_VOLUBA_NSP }}/${DOCKERIMG}
echo "Setting docker image stream to $DOCKER_IMGSTREAM"
echo "DOCKER_IMGSTREAM=$DOCKER_IMGSTREAM" >> $GITHUB_ENV
- name: 'Build docker image'
run: |
echo "Building $DOCKER_IMGSTREAM"
docker build \
-t $DOCKER_IMGSTREAM \
.
echo "Successfully built $DOCKER_IMGSTREAM"
- name: 'Push to docker registry'
run: |
echo "Login to docker registry"
docker login \
-u '${{ secrets.EBRAINS_DOCKER_REG_USER }}' \
-p '${{ secrets.EBRAINS_DOCKER_REG_TOKEN }}' \
docker-registry.ebrains.eu
echo "Pushing $DOCKER_IMGSTREAM"
docker push $DOCKER_IMGSTREAM
- name: 'Tag and push version'
if: ${{ github.ref == 'refs/heads/master' }}
run: |
VERSIONED_DOCKER_IMGSTREAM=${{ secrets.EBRAINS_DOCKER_REG_VOLUBA_NSP }}/${{ env.DOCKERIMG }}:$VERSION
echo "Tagging and pushing $VERSIONED_DOCKER_IMGSTREAM"
docker tag $DOCKER_IMGSTREAM $VERSIONED_DOCKER_IMGSTREAM
docker login \
-u '${{ secrets.EBRAINS_DOCKER_REG_USER }}' \
-p '${{ secrets.EBRAINS_DOCKER_REG_TOKEN }}' \
docker-registry.ebrains.eu
docker push $VERSIONED_DOCKER_IMGSTREAM
deploy-prod-on-rancher:
needs: [ build-docker-img ]
if: ${{ github.ref == 'refs/heads/master' && success() }}
uses: ./.github/workflows/deploy-helm.yml
with:
DEPLOYMENT_NAME: voluba-prod
IMAGE_TAG: ${{ needs.build-docker-img.outputs.VERSION }}
secrets:
KUBECONFIG: ${{ secrets.KUBECONFIG }}
deploy-rc-on-rancher:
needs: [ build-docker-img ]
if: ${{ github.ref == 'refs/heads/staging' && success() }}
uses: ./.github/workflows/deploy-helm.yml
with:
DEPLOYMENT_NAME: voluba-rc
IMAGE_TAG: staging
secrets:
KUBECONFIG: ${{ secrets.KUBECONFIG }}
deploy-rewrite-on-rancher:
needs: [ build-docker-img ]
if: ${{ github.ref == 'refs/heads/rf_rewriteFrontend' && success() }}
uses: ./.github/workflows/deploy-helm.yml
with:
DEPLOYMENT_NAME: voluba-angular
IMAGE_TAG: rf_rewriteFrontend
secrets:
KUBECONFIG: ${{ secrets.KUBECONFIG }}