This repository has been archived by the owner on Aug 23, 2024. It is now read-only.
generated from Sudokuru/.github
-
Notifications
You must be signed in to change notification settings - Fork 1
159 lines (135 loc) · 4.13 KB
/
pipeline.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
name: "Pipeline"
on:
push:
branches:
- main
pull_request:
branches:
- main
concurrency: main_workflow
permissions:
contents: write
pages: write
checks: write
id-token: write
packages: write
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18.x
- name: Install Postman CLI
run: |
curl -o- "https://dl-cli.pstmn.io/install/linux64.sh" | sh
- name: Login to Postman CLI
run: postman login --with-api-key ${{ secrets.POSTMAN_API_KEY }}
- name: Add .env file
uses: SpicyPizza/[email protected]
with:
envkey_AUTH0_AUDIENCE: ${{ secrets.BACKEND_AUTH0_AUDIENCE }}
envkey_AUTH0_BASE_URL: ${{ secrets.BACKEND_AUTH0_BASE_URL }}
envkey_MONGO_URL: mongodb://mongo:27017
directory: .
file_name: .env
fail_on_empty: true
- name: Run Docker image
run: |
npm run app
#
- name: Sleep for 20 seconds
run: sleep 20s
shell: bash
# - name: Run 500 API tests
# run: |
# postman collection run "${{ github.workspace }}/postman/collections/Sudokuru-Backend-500s.json"
- name: Run API tests
run: |
postman collection run "${{ github.workspace }}/postman/collections/Sudokuru-Backend.json" -e "${{ secrets.POSTMAN_ENV_ID }}"
- name: Dump mongo logs
if: failure()
uses: jwalton/gh-docker-logs@v2
deploy_docker_image:
name: Deploy Docker Image
if: ${{ github.ref == 'refs/heads/main' }}
needs: [ test ]
runs-on: ubuntu-latest
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Add .env file
uses: SpicyPizza/[email protected]
with:
envkey_AUTH0_AUDIENCE: ${{ secrets.BACKEND_AUTH0_AUDIENCE }}
envkey_AUTH0_BASE_URL: ${{ secrets.BACKEND_AUTH0_BASE_URL }}
envkey_MONGO_URL: mongodb://mongo:27017
directory: .
file_name: .env
fail_on_empty: true
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
name: ${{ github.repository }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
tags: "latest,${{ github.run_number }}"
deploy_documentation:
name: Deploy Documentation
if: ${{ github.ref == 'refs/heads/main' }}
needs: [ test ]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 16.x
- run: npm ci
- run: npm run update-docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: 'docs/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
deploy:
name: Deploy to AWS Lambda
if: ${{ github.ref == 'refs/heads/main' }}
needs: [ deploy_documentation, deploy_docker_image ]
runs-on: ubuntu-latest
strategy:
matrix:
environment: [ dev, prod ]
environment: ${{ matrix.environment }}
env:
AWS_ACCESS_KEY_ID: ${{secrets.AWS_ACCESS_KEY_ID}}
AWS_SECRET_ACCESS_KEY: ${{secrets.AWS_SECRET_ACCESS_KEY}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Add .env file
uses: SpicyPizza/[email protected]
with:
envkey_AUTH0_AUDIENCE: ${{ secrets.AUTH0_AUDIENCE }}
envkey_AUTH0_BASE_URL: ${{ secrets.AUTH0_BASE_URL }}
envkey_MONGO_URL: ${{secrets.DATABASE_URL}}
directory: .
file_name: .env
fail_on_empty: true
- run: npm ci
- run: npm i serverless
- name: ${{ matrix.environment }} Deployment
run: npm run deploy
env:
STAGE: ${{ matrix.environment }}