diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ce6b4a6..4bcbe86 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -16,10 +16,25 @@ jobs: steps: - uses: actions/checkout@v3 - name: Branch name - run: echo running on branch ${{ github.head_ref }} / ${{ github.ref_name }} + run: | + if [ ${{ github.head_ref }} != "" ]; then + echo running on branch ${{ github.head_ref }} + else + echo running on branch ${{ github.ref_name }} + fi - name: Login to DockerHub Registry run: echo ${{ secrets.DOCKER_HUB_PASSWORD }} | docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} --password-stdin - name: build docker image - run: docker build . --file ./docker/dockerfile --tag abmptit/docker-lab-static-website:${{ github.head_ref }}${{ github.ref_name }} + run: | + if [ ${{ github.head_ref }} != "" ]; then + docker build . --file ./docker/dockerfile --tag abmptit/docker-lab-static-website:${{ github.head_ref }} + else + docker build . --file ./docker/dockerfile --tag abmptit/docker-lab-static-website:${{ github.ref_name }} + fi - name: Push the Docker image - run: docker push abmptit/docker-lab-static-website:${{ github.head_ref }}${{ github.ref_name }} + run: | + if [ ${{ github.head_ref }} != "" ]; then + docker push abmptit/docker-lab-static-website:${{ github.head_ref }} + else + docker push abmptit/docker-lab-static-website:${{ github.ref_name }} + fi