forked from mosip/websub
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (88 loc) · 3.12 KB
/
docker-build.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
name: Docker build and push
on:
push:
branches:
- "**"
tags-ignore:
- "**"
paths:
- "consolidator/**"
- "hub/**"
- "kafka-admin-client/**"
- "*.Dockerfile"
pull_request:
branches:
- "**"
paths:
- "consolidator/**"
- "hub/**"
- "kafka-admin-client/**"
- "*.Dockerfile"
workflow_dispatch:
jobs:
docker-build-consolidator:
name: Docker Build Consolidator
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.docker_hub_organisation || 'mosipdev' }}
SERVICE_NAME: 'consolidator-websub-service'
steps:
- uses: actions/checkout@v3
- name: Docker build
run: |
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
IMAGE_ID=$NAMESPACE/$SERVICE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$BRANCH_NAME
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]; then
VERSION=develop
fi
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
echo VERSION=$VERSION >> $GITHUB_ENV
docker build . \
--file consolidator.Dockerfile \
--tag $IMAGE_ID:$VERSION
if [[ '${{ secrets.docker_hub_token }}' != '' && '${{ secrets.docker_hub_actor }}' != '' && '${{ github.event_name }}' != 'pull_request' ]]; then
echo DOCKER_PUSH=true >> $GITHUB_ENV
fi
- name: Docker Push
if: env.DOCKER_PUSH == 'true'
run: |
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}
docker-build-websub:
name: Docker Build Websub
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.docker_hub_organisation || 'mosipdev' }}
SERVICE_NAME: 'websub-service'
steps:
- uses: actions/checkout@v3
- name: Docker build
run: |
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
IMAGE_ID=$NAMESPACE/$SERVICE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$BRANCH_NAME
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]; then
VERSION=develop
fi
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
echo VERSION=$VERSION >> $GITHUB_ENV
docker build . \
--file hub.Dockerfile \
--tag $IMAGE_ID:$VERSION
if [[ '${{ secrets.docker_hub_token }}' != '' && '${{ secrets.docker_hub_actor }}' != '' && '${{ github.event_name }}' != 'pull_request' ]]; then
echo DOCKER_PUSH=true >> $GITHUB_ENV
fi
- name: Docker Push
if: env.DOCKER_PUSH == 'true'
run: |
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin
docker push ${{ env.IMAGE_ID }}:${{ env.VERSION }}