diff --git a/.github/actions/docker-build-publish/action.yml b/.github/actions/docker-build-publish/action.yml index 0f5f104..ae657be 100644 --- a/.github/actions/docker-build-publish/action.yml +++ b/.github/actions/docker-build-publish/action.yml @@ -7,12 +7,18 @@ inputs: tag-name: description: "Tag Name" required: true + image-name: + description: "Image Name" + required: true registry-username: description: "Registry username" required: true registry-password: description: "Registry password" required: true + dockerfile-path: + description: "Dockerfile path" + required: true # https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-actions runs: @@ -32,17 +38,11 @@ runs: if: ${{ github.ref == 'refs/heads/main' && success() }} shell: bash run: | - docker build -t ${{ inputs.registry-username }}/booking-microservices-flight:${{ inputs.tag-name }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" . - docker build -t ${{ inputs.registry-username }}/booking-microservices-identity:${{ inputs.tag-name }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" . - docker build -t ${{ inputs.registry-username }}/booking-microservices-passenger:${{ inputs.tag-name }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" . - docker build -t ${{ inputs.registry-username }}/booking-microservices-booking:${{ inputs.tag-name }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" . + docker build -t ${{ inputs.registry-username }}/${{ inputs.image-name }}:${{ inputs.tag-name }} -f "${{ github.workspace }}/${{ inputs.dockerfile-path }}" . - name: Publish Docker Image if: ${{ github.ref == 'refs/heads/main' && success() }} shell: bash run: | - docker push ${{ inputs.registry-username }}/booking-microservices-flight:${{ inputs.tag-name }} - docker push ${{ inputs.registry-username }}/booking-microservices-identity:${{ inputs.tag-name }} - docker push ${{ inputs.registry-username }}/booking-microservices-passenger:${{ inputs.tag-name }} - docker push ${{ inputs.registry-username }}/booking-microservices-booking:${{ inputs.tag-name }} + docker push ${{ inputs.registry-username }}/${{ inputs.image-name }}:${{ inputs.tag-name }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e23a4a3..bc4efc4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,11 +45,42 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Call Composite Action docker-build-publish - uses: ./.github/actions/docker-build-publish + - name: Build and Publish Identity to Docker if: ${{ github.ref == 'refs/heads/main' && success() }} + uses: ./.github/actions/docker-build-publish with: tag-name: ${{ steps.last_release.outputs.tag_name }} registry-username: ${{ secrets.DOCKERHUB_USERNAME }} registry-password: ${{ secrets.DOCKERHUB_PASSWORD }} + dockerfile-path: 'src/Services/Identity/Dockerfile' + image-name: 'booking-microservices-identity' + + - name: Build and Publish Flight to Docker + if: ${{ github.ref == 'refs/heads/main' && success() }} + uses: ./.github/actions/docker-build-publish + with: + tag-name: ${{ steps.last_release.outputs.tag_name }} + registry-username: ${{ secrets.DOCKERHUB_USERNAME }} + registry-password: ${{ secrets.DOCKERHUB_PASSWORD }} + dockerfile-path: 'src/Services/Flight/Dockerfile' + image-name: 'booking-microservices-flight' + + - name: Build and Publish Passenger to Docker + if: ${{ github.ref == 'refs/heads/main' && success() }} + uses: ./.github/actions/docker-build-publish + with: + tag-name: ${{ steps.last_release.outputs.tag_name }} + registry-username: ${{ secrets.DOCKERHUB_USERNAME }} + registry-password: ${{ secrets.DOCKERHUB_PASSWORD }} + dockerfile-path: 'src/Services/Passenger/Dockerfile' + image-name: 'booking-microservices-passenger' + + - name: Build and Publish Booking to Docker + if: ${{ github.ref == 'refs/heads/main' && success() }} + uses: ./.github/actions/docker-build-publish + with: + tag-name: ${{ steps.last_release.outputs.tag_name }} + registry-username: ${{ secrets.DOCKERHUB_USERNAME }} + registry-password: ${{ secrets.DOCKERHUB_PASSWORD }} + dockerfile-path: 'src/Services/Booking/Dockerfile' + image-name: 'booking-microservices-booking'