Skip to content

Commit

Permalink
Merge pull request #15 from PSNAppz/simplified
Browse files Browse the repository at this point in the history
Update Docker Workflow
  • Loading branch information
shibu-narayanan authored Jul 16, 2024
2 parents 985a131 + 8b7b173 commit 3a58d3a
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions .github/workflows/docker-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,36 @@ jobs:
name: Docker Build and Push
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.docker_hub_organisation }}
NAMESPACE: ${{ secrets.docker_hub_organisation || 'openg2p' }}
SERVICE_NAME: g2p-cash-transfer-bridge
PAYMENT_BACKEND_SERVICE_NAME: gctb-payment-backend
steps:
- uses: actions/checkout@v3
- name: Docker build and push
- name: Docker build
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
PAYMENT_BACKEND_IMAGE_ID=$NAMESPACE/$PAYMENT_BACKEND_SERVICE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
PAYMENT_BACKEND_IMAGE_ID=$(echo $PAYMENT_BACKEND_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 PAYMENT_BACKEND_IMAGE_ID=$PAYMENT_BACKEND_IMAGE_ID
echo VERSION=$VERSION
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
echo VERSION=$VERSION >> $GITHUB_ENV
docker build . \
--file Dockerfile \
--tag $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
docker build . \
--file payment-backend.Dockerfile \
--tag $PAYMENT_BACKEND_IMAGE_ID:$VERSION
docker push $PAYMENT_BACKEND_IMAGE_ID:$VERSION
if [[ '${{ secrets.docker_hub_token }}' != '' && '${{ secrets.docker_hub_actor }}' != '' ]]; then
export DOCKER_PUSH="true"
echo DOCKER_PUSH=$DOCKER_PUSH >> $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 }}

0 comments on commit 3a58d3a

Please sign in to comment.