Skip to content

Merge pull request #15 from shivamg9/develop #14

Merge pull request #15 from shivamg9/develop

Merge pull request #15 from shivamg9/develop #14

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 | 'openg2p' }}

Check failure on line 12 in .github/workflows/docker-build.yml

View workflow run for this annotation

GitHub Actions / Build Docker and Push

Invalid workflow file

The workflow is not valid. .github/workflows/docker-build.yml (Line: 12, Col: 18): Unexpected symbol: '|'. Located at position 33 within expression: secrets.docker_hub_organisation | 'openg2p'
SERVICE_NAME: openg2p-selfservice-api
steps:
- uses: actions/checkout@v3
- name: Docker build
run: |
BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')
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
echo IMAGE_ID=$IMAGE_ID >> $GITHUB_ENV
echo VERSION=$VERSION >> $GITHUB_ENV
docker build . \
--file Dockerfile \
--tag $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 }}