-
Notifications
You must be signed in to change notification settings - Fork 1
102 lines (89 loc) · 4.31 KB
/
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
# This is a basic workflow to help you get started with Actions
name: firebase functions deploy - prod server
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the develop branch
push:
branches: [ main ]
jobs:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setting Slack API
run: |
touch deployMessageToSlack.sh
echo 'curl -X POST -H 'Content-type: application/json' --data "{\"text\":\" [DEPLOY] [HAVIT_SERVER] deployment successful.\", \"icon_emoji\": \":ghost:\"}" ${{ secrets.PROD_WEB_HOOK_ERROR_MONITORING }}' >> deployMessageToSlack.sh
chmod 755 deployMessageToSlack.sh
- name: create env file
run: |
cd functions
touch .env.prod
echo "NODE_ENV=production" >> .env.prod
echo "WEB_HOOK_ERROR_MONITORING=${{ secrets.PROD_WEB_HOOK_ERROR_MONITORING }}" >> .env.prod
echo "DB_USER=${{ secrets.PROD_DB_USER }}" >> .env.prod
echo "DB_HOST=${{ secrets.PROD_DB_HOST }}" >> .env.prod
echo "DB_DB=${{ secrets.DB_DB }}" >> .env.prod
echo "DB_PASSWORD=${{ secrets.PROD_DB_PASSWORD }}" >> .env.prod
echo "JWT_SECRET=${{ secrets.PROD_JWT_SECRET }}" >> .env.prod
echo "TYPE=${{ secrets.TYPE }}" >> .env.prod
echo "PROJECT_ID=${{ secrets.PROD_PROJECT_ID }}" >> .env.prod
echo "PRIVATE_KEY=${{ secrets.PROD_PRIVATE_KEY }}" >> .env.prod
echo "PRIVATE_KEY_ID=${{ secrets.PROD_PRIVATE_KEY_ID }}" >> .env.prod
echo "CLIENT_EMAIL=${{ secrets.PROD_CLIENT_EMAIL }}" >> .env.prod
echo "CLIENT_ID=${{ secrets.PROD_CLIENT_ID }}" >> .env.prod
echo "AUTH_URI=${{ secrets.AUTH_URI }}" >> .env.prod
echo "TOKEN_URI=${{ secrets.TOKEN_URI }}" >> .env.prod
echo "AUTH_PROVIDER_CERT_URL=${{ secrets.AUTH_PROVIDER_CERT_URL }}" >> .env.prod
echo "CLIENT_CERT_URL=${{ secrets.PROD_CLIENT_CERT_URL }}" >> .env.prod
echo "PUSH_SERVER_URL=${{ secrets.PROD_PUSH_SERVER_URL }}" >> .env.prod
echo "APPLE_CLIENT_ID=${{ secrets.APPLE_CLIENT_ID}}" >> .env.prod
echo "APPLE_KEY_ID=${{ secrets.APPLE_KEY_ID }}" >> .env.prod
echo "APPLE_TEAM_ID=${{ secrets.APPLE_TEAM_ID }}" >> .env.prod
echo "APPLE_PRIVATE_KEY_FILE=${{ secrets.APPLE_PRIVATE_KEY_FILE }}" >> .env.prod
echo "JWT_ALGORITHM=${{ secrets.JWT_ALGORITHM }}" >> .env.prod
echo "JWT_ACCESS_EXPIRE=${{ secrets.JWT_ACCESS_EXPIRE }}" >> .env.prod
echo "JWT_REFRESH_EXPIRE=${{ secrets.JWT_REFRESH_EXPIRE }} " >> .env.prod
echo "SENTRY_DSN=${{ secrets.PROD_SENTRY_DSN }} " >> .env.prod
echo "SENTRY_TRACES_SAMPLE_RATE=${{ secrets.PROD_SENTRY_TRACES_SAMPLE_RATE }} " >> .env.prod
- name: create .p8 file
run: |
cd functions
touch ${{ secrets.APPLE_PRIVATE_KEY_FILE }}
echo "${{ secrets.APPLE_PRIVATE_KEY }}" > ${{ secrets.APPLE_PRIVATE_KEY_FILE }}
- name: create-json
id: create-json
uses: jsdaniell/[email protected]
with:
name: "havit-wesopt29-firebase-adminsdk-mgljp-478046b091.json"
json: ${{ secrets.FIREBASE_JSON }}
dir: 'functions/'
- name: create-json
id: create-prod-json
uses: jsdaniell/[email protected]
with:
name: "havit-production-firebase-adminsdk-bypl1-d081cc62e4.json"
json: ${{ secrets.PROD_FIREBASE_JSON }}
dir: 'functions/'
- name: Install npm pacakges
run: |
cd functions
npm install
npm install -g firebase-tools
npm install --save-dev cross-env
- name: Deploy to Firebase
run: |
cd functions
firebase use prod
npm run deploy
env:
FIREBASE_TOKEN: ${{ secrets.PROD_FIREBASE_TOKEN }}
- name: action-slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: Github Actions Dev Prod Server
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
env:
SLACK_WEBHOOK_URL: ${{ secrets.PROD_SLACK_BUILD_WEBHOOK_URL }} # required
if: always() # Pick up events even if the job fails or is canceled.