-
Notifications
You must be signed in to change notification settings - Fork 0
121 lines (115 loc) · 3.43 KB
/
staging-deploy-backend.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
name: Staging Deployment Backend
on:
workflow_dispatch:
push:
paths:
- "backend/**"
- ".github/workflows/staging-deploy-backend.yml"
- "deployments/staging-backend-deployment.yaml"
branches:
- master
jobs:
lint-format:
name: lint and format
runs-on: ubuntu-20.04
steps:
- name: checkout code
uses: actions/checkout@v4
- name: get pnpm
uses: pnpm/action-setup@v3
with:
version: 8
- name: get node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: install dependencies
run: pnpm --filter=backend -config.-dedupe-peer-dependents=false i --frozen-lockfile
- name: lint
run: pnpm run backend lint
- name: check formatting
run: |
if ! pnpm run format-check ; then
echo "Please format the code by running: pnpm run format"
exit 1
fi
test:
name: test
runs-on: ubuntu-22.04
steps:
- name: checkout code
uses: actions/checkout@v4
- name: get pnpm
uses: pnpm/action-setup@v3
with:
version: 8
- name: get node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: install dependencies
run: pnpm --filter=backend -config.-dedupe-peer-dependents=false i --frozen-lockfile
- name: test
run: pnpm run backend test
build-image:
runs-on: ubuntu-22.04
needs: [lint-format, test]
name: build & push docker image
steps:
- name: checkout code
uses: actions/checkout@v4
- name: set up QEMU
uses: docker/setup-qemu-action@v3
- name: set up docker buildx
uses: docker/setup-buildx-action@v3
- name: docker metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: notemann27/rememberry-backend
tags: |
type=raw,value=${{ github.sha }}
type=raw,value=latest
- name: log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./backend/Dockerfile
platforms: linux/amd64
push: true
tags: ${{ steps.metadata.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
push-staging:
runs-on: ubuntu-22.04
name: deploy changes on staging
#if: github.ref == 'refs/heads/master'
needs: build-image
steps:
- name: set the kubernetes context
uses: azure/k8s-set-context@v3
with:
method: service-account
k8s-url: ${{ secrets.KUBE_SERVER_URL }}
k8s-secret: ${{ secrets.KUBE_SERVICE_ACC_SECRET }}
- uses: actions/checkout@v4
name: checkout deployments
with:
submodules: "recursive"
- name: set new kustomize image tag
env:
GITHUB_SHA: ${{ github.sha }}
working-directory: "deployments/backend/base"
run: |
kustomize edit set image rem-backend-image=notemann27/rememberry-backend:$GITHUB_SHA
- name: apply new config to deploy in cluster
working-directory: "deployments/backend"
run: |
kubectl apply -k staging