name: Publish Docker Image Release

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:

  build:

    runs-on: ubuntu-latest
    if: ${{github.event.head_commit.message}} == *'build image'*

    steps:
    - uses: actions/checkout@v3
    - name: Docker Hub Login
      env:
          DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
          DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
      run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
      
    - name: Build the Docker image
      run: | 
          docker build . --file Dockerfile --tag  defuj/apkt-eis:v1.0.1-release
          docker push defuj/apkt-eis:v1.0.1-release

    
