-
Notifications
You must be signed in to change notification settings - Fork 19
145 lines (120 loc) · 4.37 KB
/
treetracker-api-build-deploy-dev.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Service CI/CD Pipeline
on:
push:
branches:
- main
env:
project-directory: ./
jobs:
test:
name: Test
runs-on: ubuntu-latest
container: node:10.18-jessie
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgis/postgis
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
rabbitmq:
image: rabbitmq
env:
RABBITMQ_DEFAULT_USER: rabbitmq
RABBITMQ_DEFAULT_PASS: rabbitmq
steps:
- uses: actions/checkout@v2
- name: Use Node.js 16.x
uses: actions/setup-node@v1
with:
node-version: '16.x'
- name: Install dependencies
run: npm install
working-directory: ${{ env.project-directory }}
- name: npm clean install
run: npm ci
working-directory: ${{ env.project-directory }}
- name: run ESLint
run: npm run lint
working-directory: ${{ env.project-directory }}
- name: run db-migrate
run: npm run db-migrate-ci
working-directory: ${{ env.project-directory }}
env:
DATABASE_URL: postgresql://postgres:postgres@postgres/postgres
- name: run api-tests
run: npm run test
working-directory: ${{ env.project-directory }}
env:
DATABASE_URL: postgresql://postgres:postgres@postgres/postgres
DATABASE_URL_LEGACYDB: postgresql://postgres:postgres@postgres/postgres
RABBIT_MQ_URL: amqp://rabbitmq:rabbitmq@rabbitmq
release:
name: Release
needs: test
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, 'skip-ci') &&
github.event_name == 'push' &&
github.repository_owner == 'Greenstand'
steps:
- uses: actions/checkout@v2
- name: Use Node.js 18.x
uses: actions/setup-node@v1
with:
node-version: '18.x'
- name: npm clean install
run: npm ci
working-directory: ${{ env.project-directory }}
- run: npm i -g semantic-release @semantic-release/{git,exec,changelog}
- run: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build snapshot and push on merge
id: docker_build_release
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: greenstand/${{ github.event.repository.name }}:${{ steps.package-version.outputs.current-version }}
- id: export_bumped_version
run: |
export BUMPED_VERSION="${{ steps.package-version.outputs.current-version }}"
echo "::set-output name=bumped_version::${BUMPED_VERSION}"
- name: Install kustomize
run: curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash
- name: Run kustomize
run: (cd deployment/overlays/development && ../../../kustomize edit set image greenstand/${{ github.event.repository.name }}:${{ steps.export_bumped_version.outputs.bumped_version }} )
- name: Commit dev kustomization file with new app version
if: |
!contains(github.event.head_commit.message, 'chore')
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git commit -am "chore: bump docker image tag ${{ steps.export_bumped_version.outputs.bumped_version }} [skip ci]"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
outputs:
bumped_version: ${{ steps.export_bumped_version.outputs.bumped_version }}