Build and push microservices #27
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 | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven | |
name: Build and push microservices | |
on: | |
#push: | |
# tags: | |
# - '*' | |
workflow_dispatch: | |
jobs: | |
build-customer: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: labs/02-eCommerce_microservices/customer | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Add hosts to /etc/hosts | |
run: | | |
sudo echo "127.0.0.1 customer-mongodb order-postgres kafka" | sudo tee -a /etc/hosts | |
- name: Get branch | |
id: get_branch | |
run: echo ::set-output name=BRANCH::$(echo $GITHUB_REF | cut -d / -f 3) | |
- name: Get the commit SHA | |
id: get_commit_sha | |
run: echo ::set-output name=COMMIT_SHA::$(git rev-parse --short "$GITHUB_SHA") | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: labs/02-eCommerce_microservices/customer/ | |
file: labs/02-eCommerce_microservices/customer/Dockerfile | |
tags: docker.io/${{ secrets.DOCKER_USERNAME }}/customer:${{ steps.get_commit_sha.outputs.COMMIT_SHA }}-${{ steps.get_branch.outputs.BRANCH }}, latest | |
build-args: | | |
TAG=docker.io/${{ steps.get_commit_sha.outputs.COMMIT_SHA }}-${{ steps.get_branch.outputs.BRANCH }} | |
add-hosts: customer-mongodb:127.0.0.1,order-postgres:127.0.0.1,kafka:127.0.0.1 | |
push: true | |
build-order: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: labs/02-eCommerce_microservices/order | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Add hosts to /etc/hosts | |
run: | | |
sudo echo "127.0.0.1 customer-mongodb order-postgres kafka" | sudo tee -a /etc/hosts | |
- name: Get branch | |
id: get_branch | |
run: echo ::set-output name=BRANCH::$(echo $GITHUB_REF | cut -d / -f 3) | |
- name: Get the commit SHA | |
id: get_commit_sha | |
run: echo ::set-output name=COMMIT_SHA::$(git rev-parse --short "$GITHUB_SHA") | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
path: labs/02-eCommerce_microservices/order/ | |
dockerfile: labs/02-eCommerce_microservices/order/Dockerfile | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
repository: ${{ secrets.DOCKER_USERNAME }}/order | |
tags: ${{ steps.get_commit_sha.outputs.COMMIT_SHA }}-${{ steps.get_branch.outputs.BRANCH }}, latest | |
build_args: | | |
TAG=${{ steps.get_commit_sha.outputs.COMMIT_SHA }}-${{ steps.get_branch.outputs.BRANCH }} | |
build-notification: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: labs/02-eCommerce_microservices/notification | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Add hosts to /etc/hosts | |
run: | | |
sudo echo "127.0.0.1 customer-mongodb order-postgres kafka" | sudo tee -a /etc/hosts | |
- name: Get branch | |
id: get_branch | |
run: echo ::set-output name=BRANCH::$(echo $GITHUB_REF | cut -d / -f 3) | |
- name: Get the commit SHA | |
id: get_commit_sha | |
run: echo ::set-output name=COMMIT_SHA::$(git rev-parse --short "$GITHUB_SHA") | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
path: labs/02-eCommerce_microservices/notification/ | |
dockerfile: labs/02-eCommerce_microservices/notification/Dockerfile | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
repository: ${{ secrets.DOCKER_USERNAME }}/notification | |
tags: ${{ steps.get_commit_sha.outputs.COMMIT_SHA }}-${{ steps.get_branch.outputs.BRANCH }}, latest | |
build_args: | | |
TAG=${{ steps.get_commit_sha.outputs.COMMIT_SHA }}-${{ steps.get_branch.outputs.BRANCH }} |