Docker hub added #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Microservices Deployment | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
# Log in to Docker Hub | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
# Build and push the specific microservice that has been updated | |
- name: Deploy Microservice | |
working-directory: backend/${{ matrix.microservice }} | |
if: ${{ github.event_path == 'backend/${{ matrix.microservice }}' || contains(github.event.commits.*.added, 'backend/${{ matrix.microservice }}') || contains(github.event.commits.*.modified, 'backend/${{ matrix.microservice }}') }} | |
run: | | |
docker-compose -f docker-compose.prod.yml build ${{ matrix.microservice }} | |
docker-compose -f docker-compose.prod.yml push ${{ matrix.microservice }} | |
# Build and push the frontend | |
- name: Deploy Frontend | |
working-directory: frontend | |
if: ${{ github.event_path == 'frontend' || contains(github.event.commits.*.added, 'frontend') || contains(github.event.commits.*.modified, 'frontend') }} | |
run: | | |
docker-compose -f docker-compose.prod.yml build frontend | |
docker-compose -f docker-compose.prod.yml push frontend | |
strategy: | |
matrix: | |
microservice: | |
- admin-microservice | |
- cart-microservice | |
- customer-microservice | |
- order-microservice | |
- seller-microservice | |
- user-microservice |