-
Notifications
You must be signed in to change notification settings - Fork 54
146 lines (117 loc) · 4.41 KB
/
treetracker-wallet-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
146
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Deploy to Dev Env
on:
push:
branches:
- master
env:
project-directory: ./
jobs:
build:
name: Release and Build
runs-on: ubuntu-latest
if: |
!contains(github.event.head_commit.message, 'skip-ci') &&
github.event_name == 'push' &&
github.repository == 'Greenstand/treetracker-wallet-api'
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: npm i -g semantic-release @semantic-release/{git,exec,changelog}
- run: semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: npm clean install
run: npm ci
working-directory: ${{ env.project-directory }}
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
with:
path: ./
- 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 with git sha and push on merge
id: docker_build_snapshot_merge
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
push: true
tags: greenstand/treetracker-wallet-api:${{ steps.package-version.outputs.current-version }}
- shell: bash
run: |
echo '${{ steps.package-version.outputs.current-version }}' > image-tag
- name: persist tag name
uses: actions/upload-artifact@v4
with:
name: image-tag-${{github.sha}}
path: image-tag
deploy:
name: Deploy latest to development environment
runs-on: ubuntu-latest
needs: build
if: |
!contains(github.event.head_commit.message, 'skip-ci') &&
github.event_name == 'push' &&
github.repository == 'Greenstand/${{ github.event.repository.name }}'
steps:
- uses: actions/checkout@v4
- name: get-npm-version
id: package-version
uses: martinbeentjes/npm-get-version-action@master
with:
path: ./
- name: Download tag name
uses: actions/download-artifact@v4
with:
name: image-tag-${{github.sha}}
- name: Set image tag name
id: image-tag-name
run: |
value=`cat image-tag`
echo "::set-output name=image-tag-name::$value"
- 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/treetracker-wallet-api:${{ steps.image-tag-name.outputs.image-tag-name }} )
- name: Install doctl for kubernetes
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DEV_DIGITALOCEAN_TOKEN }}
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ${{ secrets.DEV_CLUSTER_NAME}}
- name: Delete completed migration jobs prior to deployment
run: kubectl -n wallet-api delete job --ignore-not-found=true wallet-db-migration-job
- name: Update kubernetes resources
run: kustomize build deployment/overlays/development | kubectl apply -n ${{ secrets.K8S_NAMESPACE }} --wait -f -
# - name: Attempt to wait for migration job to complete
# run: kubectl wait --for=condition=complete --timeout=45s job/wallet-db-migration-job
test:
name: End to End Test
runs-on: ubuntu-latest
needs: deploy
env:
ENVIRONMENT: dev
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install mocha
run: npm install -g mocha
- run: npm ci
- run: echo ${{ secrets.DEVELOPMENT_ENV }}
- run: ${{ secrets.DEVELOPMENT_ENV }} npm run test-e2e