forked from OpenG2P/openg2p-spar-mapper-api
-
Notifications
You must be signed in to change notification settings - Fork 0
40 lines (34 loc) · 1.13 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
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 }}
SERVICE_NAME: openg2p-spar-mapper-api
steps:
- uses: actions/checkout@v3
- name: Docker build and push
run: |
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
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
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
docker build . \
--file Dockerfile \
--tag $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION