-
Notifications
You must be signed in to change notification settings - Fork 7
54 lines (48 loc) · 1.8 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
name: Build Docker and Push
on:
push:
workflow_dispatch:
jobs:
docker-build:
name: Docker Build and Push
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.docker_hub_organisation }}
SELFSERVICE_SERVICE_NAME: "openg2p-selfservice-ui"
steps:
- uses: actions/checkout@v3
- name: Setup branch and env
run: |
# Strip git ref prefix from version
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
VERSION=$BRANCH_NAME
if [[ $BRANCH_NAME == master || $BRANCH_NAME == main ]]; then
VERSION=develop
fi
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Build docker
run: |
SELFSERVICE_IMAGE_ID=$NAMESPACE/$SELFSERVICE_SERVICE_NAME
# Change all uppercase to lowercase
SELFSERVICE_IMAGE_ID=$(echo $SELFSERVICE_IMAGE_ID | tr '[A-Z]' '[a-z]')
echo SELFSERVICE_IMAGE_ID=$SELFSERVICE_IMAGE_ID
echo VERSION=$VERSION
echo "SELFSERVICE_IMAGE_ID=$SELFSERVICE_IMAGE_ID" >> $GITHUB_ENV
docker build . \
--file Dockerfile \
--tag $SELFSERVICE_IMAGE_ID:$VERSION
docker build . \
--file Dockerfile.no-runtime-build \
--tag $SELFSERVICE_IMAGE_ID:$VERSION-no-runtime-build
- name: Docker login
run: |
echo "${{ secrets.docker_hub_token }}" | docker login -u ${{ secrets.docker_hub_actor }} --password-stdin
if [ $? -ne 0 ];then
echo "::error::Failed to Login to dockerhub"
exit 1;
fi
- name: Docker Push images
run: |
docker push $SELFSERVICE_IMAGE_ID:$VERSION
docker push $SELFSERVICE_IMAGE_ID:$VERSION-no-runtime-build