refactor ci.yml

This commit is contained in:
meysamhadeli 2023-01-26 15:24:54 +03:30
parent 4c31d2ced2
commit 4901cee763

View File

@ -39,7 +39,7 @@ jobs:
run: dotnet test -c Release --no-restore
- name: Update Release Drafter
if: github.ref == 'refs/heads/main'
if: ${{ github.ref == 'refs/heads/main' && success() }}
id: last_release
uses: release-drafter/release-drafter@v5
env:
@ -49,13 +49,13 @@ jobs:
##ref: https://event-driven.io/en/how_to_buid_and_push_docker_image_with_github_actions
- name: Login to DockerHub
uses: docker/login-action@v2
if: ${{ github.ref == 'refs/heads/main' && success() && github.event_name == 'pull_request' }}
if: ${{ github.ref == 'refs/heads/main' && success() }}
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build Docker Image
if: ${{ github.ref == 'refs/heads/main' && success() && github.event_name == 'pull_request' }}
if: ${{ github.ref == 'refs/heads/main' && success() }}
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" .
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" .
@ -63,7 +63,7 @@ jobs:
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-booking:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" .
- name: Publish Docker Image
if: ${{ github.ref == 'refs/heads/main' && success() && github.event_name == 'pull_request' }}
if: ${{ github.ref == 'refs/heads/main' && success() }}
run: |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-flight:${{ steps.last_release.outputs.tag_name }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-identity:${{ steps.last_release.outputs.tag_name }}