booking-microservices/.github/workflows/build-publish-docker.yml
meysamhadeli 5c958636e9 .
2023-01-25 03:05:26 +03:30

69 lines
3.4 KiB
YAML

name: build-publish-docker
on:
push:
branches: [ develop ]
pull_request:
jobs:
build-and-push-docker-image:
name: Build and Publish Docker image to DockerHub
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*'
- name: Semantic Release Version
id: semantic-version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# because of using none default (conventionalcommits) `preset` for `semantic-release`, we should add dependency `conventional-changelog-conventionalcommits`
# using dry-run here for preventing publish release note and just calculate version
run: npx -p @semantic-release/git -p @semantic-release/changelog -p @semantic-release/exec semantic-release --dry-run
- name: Semantic Release Versions Outputs
run: |
echo ${{ steps.semantic-version.outputs.semantic_nextRelease_version }}
echo ${{ steps.semantic-version.outputs.semantic_nextRelease_channel }}
echo ${{ steps.semantic-version.outputs.semantic_nextRelease_gitTag }}
echo ${{ steps.semantic-version.outputs.semantic_lastRelease_version }}
echo ${{ steps.semantic-version.outputs.semantic_lastRelease_channel }}
echo ${{ steps.semantic-version.outputs.semantic_lastRelease_gitTag }}
- name: Update Application Version
run: ./update-version.sh ${{ steps.semantic-version.outputs.semantic_nextRelease_version }}
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: '🔧 chore(release): ${{ steps.semantic-version.outputs.semantic_nextRelease_version }} [skip ci]'
file_pattern: '**/Directory.Packages.props'
disable_globbing: true
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build image
run: |
docker build -t meysamh66/booking-microservices-flight:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Flight/Dockerfile" .
docker build -t meysamh66/booking-microservices-identity:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Identity/Dockerfile" .
docker build -t meysamh66/booking-microservices-passenger:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Passenger/Dockerfile" .
docker build -t meysamh66/booking-microservices-booking:${{ steps.semantic-version.outputs.semantic_nextRelease_version }} -f "${{ github.workspace }}/src/Services/Booking/Dockerfile" .
- name: Publish image
run: |
docker push meysamh66/booking-microservices-flight:${{ steps.semantic-version.outputs.semantic_nextRelease_version }}
docker push meysamh66/booking-microservices-identity:${{ steps.semantic-version.outputs.semantic_nextRelease_version }}
docker push meysamh66/booking-microservices-passenger:${{ steps.semantic-version.outputs.semantic_nextRelease_version }}
docker push meysamh66/booking-microservices-booking:${{ steps.semantic-version.outputs.semantic_nextRelease_version }}