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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | |
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Common pipeline for all services | |
on: | |
push: | |
branches: [ | |
"config-service", | |
"gateway-service", | |
"discovery-service", | |
"order-service", | |
"payment-service", | |
"profile-service", | |
"product-service" | |
] | |
pull_request: | |
branches: [ | |
"config-service", | |
"gateway-service", | |
"discovery-service", | |
"order-service", | |
"payment-service", | |
"profile-service", | |
"product-service" | |
] | |
jobs: | |
build-config-service: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/config-service' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build config-service artifact | |
run: mvn -pl config-service clean install | |
- name: Deploy app | |
run: cd config-service && | |
docker build -t ${{ secrets.DOCKER_HUB_LOGIN }}/config-service:latest -f- ./ < Dockerfile && | |
docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} && | |
docker push ${{ secrets.DOCKER_HUB_LOGIN }}/config-service:latest | |
build-gateway-service: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/gateway-service' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build gateway-service artifact | |
run: mvn -pl gateway-service clean install | |
- name: Deploy app | |
run: cd gateway-service && | |
docker build -t ${{ secrets.DOCKER_HUB_LOGIN }}/gateway-service:latest -f- ./ < Dockerfile && | |
docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} && | |
docker push ${{ secrets.DOCKER_HUB_LOGIN }}/gateway-service:latest | |
build-discovery-service: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/discovery-service' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build discovery-service artifact | |
run: mvn -pl discovery-service clean install | |
- name: Deploy app | |
run: cd discovery-service && | |
docker build -t ${{ secrets.DOCKER_HUB_LOGIN }}/discovery-service:latest -f- ./ < Dockerfile && | |
docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} && | |
docker push ${{ secrets.DOCKER_HUB_LOGIN }}/discovery-service:latest | |
build-order-service: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/order-service' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build order-service artifact | |
run: mvn -pl order-service clean install -Dmaven.test.skip=true | |
- name: Deploy app | |
run: cd order-service && | |
docker build -t ${{ secrets.DOCKER_HUB_LOGIN }}/order-service:latest -f- ./ < Dockerfile && | |
docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} && | |
docker push ${{ secrets.DOCKER_HUB_LOGIN }}/order-service:latest | |
build-profile-service: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/profile-service' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build profile-service artifact | |
run: mvn -pl profile-service clean install -Dmaven.test.skip=true | |
- name: Deploy app | |
run: cd profile-service && | |
docker build -t ${{ secrets.DOCKER_HUB_LOGIN }}/profile-service:latest -f- ./ < Dockerfile && | |
docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} && | |
docker push ${{ secrets.DOCKER_HUB_LOGIN }}/profile-service:latest | |
build-payment-service: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/payment-service' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build payment-service artifact | |
run: mvn -pl payment-service clean install -Dmaven.test.skip=true | |
- name: Deploy app | |
run: cd payment-service && | |
docker build -t ${{ secrets.DOCKER_HUB_LOGIN }}/payment-service:latest -f- ./ < Dockerfile && | |
docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} && | |
docker push ${{ secrets.DOCKER_HUB_LOGIN }}/payment-service:latest | |
build-product-service: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/product-service' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Build product-service artifact | |
run: mvn -pl product-service clean install -Dmaven.test.skip=true | |
- name: Deploy app | |
run: cd product-service && | |
docker build -t ${{ secrets.DOCKER_HUB_LOGIN }}/product-service:latest -f- ./ < Dockerfile && | |
docker login -u ${{ secrets.DOCKER_HUB_LOGIN }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} && | |
docker push ${{ secrets.DOCKER_HUB_LOGIN }}/product-service:latest |