-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (97 loc) · 3.86 KB
/
ci.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
name: CI
on: push
jobs:
buildAndTest:
name: CI Pipeline
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
submodules: true
- name: Run test
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml run -T auth npm run test
bumpVersion:
name: 'Bump Version on main'
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: buildAndTest
outputs:
newTag: ${{ steps.version-bump.outputs.newTag }}
steps:
- name: 'Checkout source code'
uses: 'actions/checkout@v2'
with:
ref: ${{ github.ref }}
- name: 'Automated Version Bump'
id: version-bump
uses: 'phips28/gh-action-bump-version@master'
with:
tag-prefix: 'v'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
buildAndPushImage:
name: Build and Push docker image
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || startsWith(github.ref,'refs/heads/hotfix/')
needs: bumpVersion
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
- name: Install Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-3
- name: Login to ECR
uses: docker/login-action@v1
with:
registry: 275440070213.dkr.ecr.eu-west-3.amazonaws.com
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
275440070213.dkr.ecr.eu-west-3.amazonaws.com/auth
tags: |
type=ref,event=branch
type=sha
type=semver,pattern={{version}},value=${{needs.bumpVersion.outputs.newTag}}
type=semver,pattern={{major}}.{{minor}},value=${{needs.bumpVersion.outputs.newTag}}
type=semver,pattern={{raw}},value=${{needs.bumpVersion.outputs.newTag}}
- name: Set correct version
run: npm version ${{needs.bumpVersion.outputs.newTag}} --allow-same-version=true --git-tag-version=false
- name: Build
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
autodeploy:
name: Auto deploy main to dev.auth.thx.network
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
needs: buildAndPushImage
steps:
- name: Install Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: 16.x
- name: Install deploy-scripts
run: npm install -g thxprotocol/deploy-scripts
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-3
- name: Deploy-script
run: thx-deploy AuthDev sha-$(echo ${{github.sha}} | cut -c1-7)