-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (172 loc) · 6 KB
/
ci-cd.prod.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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# name: CI/CD Production Pipeline
# on:
# push:
# branches:
# - main
# pull_request:
# branches:
# - main
# concurrency:
# group: ${{ github.workflow }}-${{ github.ref }}
# cancel-in-progress: true
# jobs:
# build:
# runs-on: ubuntu-latest
# environment: production
# steps:
# - name: Checkout code
# uses: actions/checkout@v3
# - name: Setup Node.js
# uses: actions/setup-node@v3
# with:
# node-version: '18' # Using Node.js version 18
# - name: Install dependencies
# run: |
# cd ./satsquare
# npm install
# - name: Run prisma commands and build
# run: |
# export DATABASE_URL=${{ secrets.DATABASE_URL }}
# export NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }}
# export NEXT_PUBLIC_LNURL_AUTH_PUBLIC_KEY=${{ secrets.NEXT_PUBLIC_LNURL_AUTH_PUBLIC_KEY }}
# export NEXT_PUBLIC_SITE_URL=${{ secrets.NEXT_PUBLIC_SITE_URL }}
# export NEXT_PUBLIC_SOCKET_URL=${{ secrets.NEXT_PUBLIC_SOCKET_URL }}
# export REDIS_URL=${{ secrets.REDIS_URL }}
# cd ./satsquare
# npx prisma generate
# npx prisma db push
# npm run seed
# npm run build
# lint:
# needs: build
# runs-on: ubuntu-latest
# environment: production
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: '18'
# - run: |
# cd ./satsquare
# npm ci
# npm run lint
# unit-tests:
# needs: build
# runs-on: ubuntu-latest
# environment: production
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: '18'
# - run: |
# cd ./satsquare
# npm ci
# npm run test
# e2e-tests:
# needs: build
# environment: production
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: '18'
# - run: |
# export DATABASE_URL=${{ secrets.DATABASE_URL }}
# export NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }}
# export NEXT_PUBLIC_LNURL_AUTH_PUBLIC_KEY=${{ secrets.NEXT_PUBLIC_LNURL_AUTH_PUBLIC_KEY }}
# export NEXT_PUBLIC_SITE_URL=${{ secrets.NEXT_PUBLIC_SITE_URL }}
# export NEXT_PUBLIC_SOCKET_URL=${{ secrets.NEXT_PUBLIC_SOCKET_URL }}
# export REDIS_URL=${{ secrets.REDIS_URL }}
# cd ./satsquare
# npm ci
# npm run test:e2e
# deps-vulnerability:
# needs: [e2e-tests, unit-tests]
# runs-on: ubuntu-latest
# environment: production
# steps:
# - uses: actions/checkout@v3
# - run: |
# cd ./satsquare
# npm ci
# npm audit --audit-level=moderate
# codecov:
# needs: deps-vulnerability
# runs-on: ubuntu-latest
# environment: production
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: '18'
# - run: |
# cd ./satsquare
# npm ci
# npm run test -- --coverage
# - uses: codecov/codecov-action@v3
# with:
# token: ${{ secrets.CODECOV_TOKEN }}
# lighthouse:
# needs: codecov
# runs-on: ubuntu-latest
# environment: production
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# with:
# node-version: '18'
# - run: |
# cd ./satsquare
# npm install
# npx lhci autorun
# docker-deploy:
# needs: lighthouse
# runs-on: ubuntu-latest
# environment: production
# permissions:
# contents: read
# packages: write
# steps:
# - uses: actions/checkout@v3
# - uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - run: |
# export DATABASE_URL=${{ secrets.DATABASE_URL }}
# export NEXTAUTH_SECRET=${{ secrets.NEXTAUTH_SECRET }}
# export NEXT_PUBLIC_LNURL_AUTH_PUBLIC_KEY=${{ secrets.NEXT_PUBLIC_LNURL_AUTH_PUBLIC_KEY }}
# export NEXT_PUBLIC_SITE_URL=${{ secrets.NEXT_PUBLIC_SITE_URL }}
# export NEXT_PUBLIC_SOCKET_URL=${{ secrets.NEXT_PUBLIC_SOCKET_URL }}
# export REDIS_URL=${{ secrets.REDIS_URL }}
# cd ./satsquare
# docker build -f Dockerfile.prod --build-arg DATABASE_URL=${{ secrets.DATABASE_URL }} --build-arg NEXTAUTH_SECRET="${{ github.sha }}" -t ghcr.io/ismail-mouyahada/master-satsquare-app:prod-${{ github.sha }} .
# - uses: aquasecurity/[email protected]
# with:
# image-ref: ghcr.io/ismail-mouyahada/master-satsquare-app:prod-${{ github.sha }}
# - run: docker push ghcr.io/ismail-mouyahada/master-satsquare-app:prod-${{ github.sha }}
# notify:
# needs: docker-deploy
# runs-on: ubuntu-latest
# environment: production
# steps:
# - name: Notification de succès 🎉
# uses: containrrr/shoutrrr-action@v1
# if: success()
# with:
# url: ${{ secrets.DISCORD_WEBHOOK_URL }}
# title: "🚀 Déploiement réussi : ${{ github.sha }} sur PRODUCTION 🎉"
# message: "Voir les modifications : ${{ github.event.compare }}."
# username: "PreproductionBOT"
# avatar: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR9SYdK1M7jEIJgdj9foHiEoUdUiYxfREv3jg&s"
# - name: Notification échec 💥
# uses: containrrr/shoutrrr-action@v1
# if: failure()
# with:
# url: ${{ secrets.DISCORD_WEBHOOK_URL }}
# message: "❗ Consultez les logs pour plus de détails. Voir les modifications : ${{ github.event.compare }}."
# username: "PreproductionBOT"
# avatar: "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR9SYdK1M7jEIJgdj9foHiEoUdUiYxfREv3jg&s"