Fixed conditional #5
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: Build and publish | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ "main" ] | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
env: | |
continue: 'false' | |
strategy: | |
matrix: | |
service: | |
- name: 'trycatchlearn/auction-svc' | |
path: 'src/AuctionService' | |
- name: 'trycatchlearn/search-svc' | |
path: 'src/SearchService' | |
- name: 'trycatchlearn/bid-svc' | |
path: 'src/BiddingService' | |
- name: 'trycatchlearn/identity-svc' | |
path: 'src/IdentityService' | |
- name: 'trycatchlearn/gateway-svc' | |
path: 'src/GatewayService' | |
- name: 'trycatchlearn/notify-svc' | |
path: 'src/NotificationService' | |
- name: 'trycatchlearn/web-app' | |
path: 'frontend/web-app' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Check for changes in service path | |
run: | | |
if git diff --quiet HEAD^ HEAD -- ${{matrix.service.path}}; then | |
echo "No changes in ${{matrix.service.path}}. Skipping build" | |
echo "continue=false" >> $GITHUB_ENV | |
else | |
echo "Changes detected in ${{matrix.service.path}}. Proceeding with build" | |
echo "continue=true" >> $GITHUB_ENV | |
fi | |
- name: Set up Docker buildx | |
if: env.continue == 'true' | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker | |
if: env.continue == 'true' | |
uses: docker/login-action@v3 | |
with: | |
username: ${{secrets.DOCKER_USERNAME}} | |
password: ${{secrets.DOCKER_TOKEN}} | |
- name: Build and push docker image | |
if: env.continue == 'true' | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ${{matrix.service.path}}/Dockerfile | |
push: true | |
tags: ${{matrix.service.name}}:latest |