Skip to content

Commit f91bf6f

Browse files
reusable for production deployment
1 parent 0d433a1 commit f91bf6f

File tree

1 file changed

+7
-49
lines changed

1 file changed

+7
-49
lines changed

.github/workflows/production.yml

Lines changed: 7 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -2,52 +2,10 @@ name: Production deployment
22
on:
33
workflow_dispatch:
44
jobs:
5-
checkout:
6-
runs-on: [self-hosted, prod]
7-
environment: production
8-
steps:
9-
- name: Get code
10-
uses: actions/checkout@v4
11-
- name: Cache dependencies
12-
id: cache
13-
uses: actions/cache@v4
14-
with:
15-
path: node_modules
16-
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
17-
- name: Install dependencies
18-
if: steps.cache.outputs.cache-hit != 'true'
19-
run: npm ci
20-
create_env:
21-
needs: checkout
22-
runs-on: [self-hosted, prod]
23-
environment: production
24-
steps:
25-
- name: Create .env file
26-
run: |
27-
echo "DB_HOST=${{ secrets.DB_HOST }}" >> production.env
28-
echo "DB_PORT=${{ secrets.DB_PORT }}" >> production.env
29-
echo "DB_USER=${{ secrets.DB_USER }}" >> production.env
30-
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> production.env
31-
echo "DB_NAME=${{ secrets.DB_NAME }}" >> production.env
32-
echo "AUTH_SECRET=${{ secrets.AUTH_SECRET }}" >> production.env
33-
echo "JWT_EXPIRES_IN=${{ secrets.JWT_EXPIRES_IN }}" >> production.env
34-
echo "PORT=${{ vars.PORT }}" >> production.env
35-
test:
36-
runs-on: [self-hosted, prod]
37-
needs: checkout
38-
steps:
39-
- name: Run tests
40-
run: npm run test
41-
build:
42-
needs: [create_env, test]
43-
runs-on: [self-hosted, prod]
44-
steps:
45-
- name: Build website
46-
id: build-website
47-
run: npm run build
48-
deploy:
49-
needs: build
50-
runs-on: [self-hosted, prod]
51-
steps:
52-
- name: Run deployment
53-
run: NODE_ENV=production pm2 restart dist/main.js --name=events-api
5+
run-deployment:
6+
uses: ./.github/workflows/deployment.yml
7+
with:
8+
environment: "production"
9+
runner: "prod"
10+
env_file: "production.env"
11+
secrets: inherit

0 commit comments

Comments
 (0)