-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (100 loc) · 3.38 KB
/
ci.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
name: Node Auth Application Pipeline
# Trigger the workflow
on:
push:
branches:
- '**' # Matches every branch for push events
pull_request:
branches:
- '**' # Matches every branch for pull request events
jobs:
# Step: Cache and Install Dependencies
npm:
uses: SAINIAbhishek/shared-workflows/.github/workflows/cache-install-dependencies.yml@main
with:
node-version: '20.17.0'
lock-file: 'package-lock.json'
cache-path: 'node_modules'
cache-key-prefix: 'auth'
working-directory: './'
# Step: Lint the code
lint:
needs: [npm] # Wait for dependencies to be installed before linting
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
# Restore Modules cache
- name: Restore Modules Cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-auth-${{ hashFiles('package-lock.json') }}
# Lint the server code
- name: Checking Linting
run: npm run lint
working-directory: ./
# Step: Formatting
format:
needs: [npm] # Dependencies must be installed before formatting
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
# Restore Modules cache
- name: Restore Modules Cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-auth-${{ hashFiles('package-lock.json') }}
# Format the code with Prettier
- name: Checking Formatting with Prettier
run: npm run prettier
working-directory: ./
# Step: Security audit
dependencies-check:
needs: [npm]
uses: SAINIAbhishek/shared-workflows/.github/workflows/security-audit.yml@main
with:
node-version: '20.17.0'
lock-file: 'package-lock.json'
cache-path: 'node_modules'
cache-key-prefix: 'auth'
working-directory: './'
# Step: Build the project
build:
needs: [lint, format, dependencies-check]
runs-on: ubuntu-latest
environment: development
steps:
- name: Checkout Code
uses: actions/checkout@v3
# Restore Modules cache
- name: Restore Modules Cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-auth-${{ hashFiles('package-lock.json') }}
- name: Build for development
run: npm run build
working-directory: ./
env:
PORT: ${{ vars.API_PORT }}
MONGO_URI: ${{ vars.MONGO_URI }}
MONGO_DB_HOST: ${{ vars.MONGO_DB_HOST }}
TOKEN_ISSUER: ${{ vars.TOKEN_ISSUER}}
TOKEN_AUDIENCE: ${{ vars.TOKEN_AUDIENCE}}
CORS_URL: ${{ vars.CORS_URL}}
FRONTEND_RESET_URL: ${{ vars.FRONTEND_RESET_URL}}
API_VERSION: ${{ vars.API_VERSION}}
ACCESS_TOKEN_SECRET_KEY: ${{ secrets.ACCESS_TOKEN_SECRET_KEY}}
MAILTRAP_TESTING_USERNAME: ${{ secrets.MAILTRAP_TESTING_USERNAME}}
MAILTRAP_TESTING_PASSWORD: ${{ secrets.MAILTRAP_TESTING_PASSWORD}}
MAILTRAP_TESTING_HOST: ${{ vars.MAILTRAP_TESTING_HOST}}
REFRESH_TOKEN_SECRET_KEY: ${{ secrets.REFRESH_TOKEN_SECRET_KEY}}
MAILTRAP_EMAIL_ENV: ${{ vars.MAILTRAP_EMAIL_ENV}}
- name: Save Devlopment Build Artifacts
uses: actions/upload-artifact@v4
with:
name: dev-build
path: build