Merge pull request #165 from meysamhadeli/develop

chore: Update ci.yml
This commit is contained in:
Meysam Hadeli 2023-02-07 18:11:06 +03:30 committed by GitHub
commit 215ef9c3fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 53 additions and 24 deletions

View File

@ -0,0 +1,46 @@
name: "Publish and Build Docker"
description: "Publish and Build Docker "
# Input parameters allow you to specify data that the action expects to use during runtime. GitHub stores input parameters as environment variables.(so they are just string)
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#inputs
inputs:
tag-name:
description: "Tag Name"
required: true
registry-username:
description: "Registry username"
required: true
registry-password:
description: "Registry password"
required: true
# https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-composite-actions
runs:
using: "composite"
steps:
##ref: https://docs.docker.com/language/golang/configure-ci-cd/
##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() }}
with:
username: ${{ inputs.registry-username }}
password: ${{ inputs.registry-password }}
- name: Build Docker Image
if: ${{ github.ref == 'refs/heads/main' && success() }}
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" .
- name: Publish Docker Image
if: ${{ github.ref == 'refs/heads/main' && success() }}
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 }}

View File

@ -45,28 +45,11 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
##ref: https://docs.docker.com/language/golang/configure-ci-cd/
##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
- name: Call Composite Action docker-build-publish
uses: ./.github/actions/docker-build-publish
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() }}
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" .
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-passenger:${{ steps.last_release.outputs.tag_name }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" .
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() }}
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 }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-passenger:${{ steps.last_release.outputs.tag_name }}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/booking-microservices-booking:${{ steps.last_release.outputs.tag_name }}
tag-name: ${{ steps.last_release.outputs.tag_name }}
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_PASSWORD }}

View File

@ -15,7 +15,7 @@ jobs:
steps:
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter.yml
config-name: release-drafter-template.yml
disable-releaser: true # only run auto-labeler for PRs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}