Skip to content

Build Docker and Push #3

Build Docker and Push

Build Docker and Push #3

Workflow file for this run

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