-
Notifications
You must be signed in to change notification settings - Fork 77
101 lines (95 loc) · 4.02 KB
/
build-docker-images.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# 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 }}
password: ${{ secrets.DOCKER_PERSONAL_ACCESS_TOKEN }}
- 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: ${{ secrets.DOCKER_USERNAME }}/customer:${{ 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 }}
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 }}