Skip to content

Merge pull request #2 from lalithkota/develop #1

Merge pull request #2 from lalithkota/develop

Merge pull request #2 from lalithkota/develop #1

Workflow file for this run

name: Build Docker and Push
on:
push:
branches:
- '**'
tags-ignore:
- '**'
workflow_dispatch:
jobs:
docker-build:
name: Docker Build and Push
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.docker_hub_organisation }}
IMAGE_NAME: "openg2p-social-registry-landing"
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 selfservice docker
run: |
IMAGE_ID=$NAMESPACE/$IMAGE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
echo "IMAGE_ID=$IMAGE_ID" >> $GITHUB_ENV
docker build . \
--file Dockerfile \
--tag $IMAGE_ID:$VERSION
- 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 $IMAGE_ID:$VERSION