-
Notifications
You must be signed in to change notification settings - Fork 12
126 lines (111 loc) · 3.44 KB
/
main.yml
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Build
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:
jobs:
bump:
runs-on: ubuntu-latest
name: Bump version
outputs:
bumped_sha: ${{ steps.sha.outputs.SHA }}
new_version: ${{ steps.version.outputs.VERSION }}
steps:
- uses: actions/checkout@v3
- name: Bump version
uses: remorses/bump-version@js
with:
version_file: ./VERSION
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: github.ref == 'refs/heads/master'
- name: Get Version
id: version
run: |
echo ::set-output name=VERSION::$(cat ./VERSION)
if: github.ref == 'refs/heads/master'
- name: Push changes to master
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tags: true
if: github.ref == 'refs/heads/master'
- name: get sha
id: sha
run: |
sha_new=$(git rev-parse HEAD)
echo $sha_new
echo "::set-output name=SHA::$sha_new"
if: github.ref == 'refs/heads/master'
- run:
echo ${{ steps.sha.outputs.SHA }}
if: github.ref == 'refs/heads/master'
build:
needs: bump
runs-on: ubuntu-latest
strategy:
matrix:
service:
- otel-collector
- mongodb
- redis
- rabbitmq
- mysql
- dispatch
- front
- web
- cart
- catalogue
- user
- payment
- shipping
- ratings
- load
env:
SERVICE: ${{matrix.service}}
DOCKER_BUILDKIT: 1
steps:
- name: Fetch updated source through SHA from bump
uses: actions/checkout@v3
with:
ref: ${{ needs.bump.outputs.bumped_sha }}
fetch-depth: 0
if: github.ref == 'refs/heads/master'
- name: Fetch source from event
uses: actions/checkout@v3
if: github.ref != 'refs/heads/master'
- run: cp env.template .env
shell: bash
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
if: github.ref == 'refs/heads/master'
- name: Pull service ${{matrix.service}}
run: docker-compose -f docker-compose.yaml -f docker-compose-load.yaml -f docker-compose-collector.yaml pull --ignore-pull-failures ${{matrix.service}}
- name: Build service ${{matrix.service}}
run: docker-compose -f docker-compose.yaml -f docker-compose-load.yaml -f docker-compose-collector.yaml build ${{matrix.service}}
- name: Push service ${{matrix.service}}
run: docker-compose -f docker-compose.yaml -f docker-compose-load.yaml -f docker-compose-collector.yaml push ${{matrix.service}}
if: github.ref == 'refs/heads/master'
create_release:
needs:
- bump
- build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ needs.bump.outputs.SHA }}
fetch-depth: 0
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.STAN_TOKEN }}
run: |
gh release create ${{ needs.bump.outputs.new_version }} \
--title "v${{ needs.bump.outputs.new_version }}" \
--generate-notes
if: github.ref == 'refs/heads/master'