generated from ecomplus/application-starter
-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (113 loc) · 4.04 KB
/
deploy.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
name: Deploy
on:
push:
branches:
- master
paths:
- 'functions/**'
- 'scripts/_constants.js'
- 'scripts/firebase-deploy.js'
- '*.json'
jobs:
deploy:
name: Deploy to Firebase
runs-on: ubuntu-latest
if: |
github.event.head_commit.message != 'Initial commit' &&
!contains(github.event.head_commit.message, '[skip ci]')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: '16.x'
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install root dependencies
run: npm ci --only=production
- name: Install functions dependencies
run: cd functions && npm ci --only=production --no-optional && cd ..
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run deploy
env:
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
SERVER_OPERATOR_TOKEN: ${{ secrets.SERVER_OPERATOR_TOKEN }}
ID_GALAXPAY_PARTNER: ${{ secrets.ID_GALAXPAY_PARTNER }}
HASH_GALAXPAY_PARTNER: ${{ secrets.HASH_GALAXPAY_PARTNER }}
run: npm run deploy
update-app-json:
name: Update application and publish
runs-on: ubuntu-latest
needs: deploy
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Write README with base URI
env:
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
run: |
echo "App base URI: https://us-central1-$FIREBASE_PROJECT_ID.cloudfunctions.net/app/" \
> ./assets/README
- name: Run Wget and write to JSON file
env:
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
run: |
sleep 20
wget -O ./assets/application.json \
https://us-central1-$FIREBASE_PROJECT_ID.cloudfunctions.net/app/
- name: Config Git and check diff
run: |
git config --local user.email '[email protected]'
git config --local user.name 'GitHub Action'
git add ./assets/
(git diff-index --quiet HEAD && echo "::set-output name=diff::0") || echo "::set-output name=diff::1"
id: git_diff
- name: Commit local file changes
if: steps.git_diff.outputs.diff == 1
run: |
git commit -m 'chore(assets): update application body [skip ci]'
- name: Push changes
if: steps.git_diff.outputs.diff == 1
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
- name: Check stable package version
env:
APP_CHANGED: ${{ steps.git_diff.outputs.diff }}
run: |
CAN_PUBLISH=$(node -p "!(/-/.test(require('./package.json').version)) && process.env.APP_CHANGED")
echo "::set-output name=publish::$CAN_PUBLISH"
id: pkg_version
- name: Setup Node
if: steps.pkg_version.outputs.publish == 1
uses: actions/setup-node@v2
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org/'
- name: Cache dependencies
if: steps.pkg_version.outputs.publish == 1
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
if: steps.pkg_version.outputs.publish == 1
run: npm ci --only=production
- name: Run publish script
if: steps.pkg_version.outputs.publish == 1
env:
FIREBASE_PROJECT_ID: ${{ secrets.FIREBASE_PROJECT_ID }}
MARKET_TOKEN: ${{ secrets.MARKET_TOKEN }}
run: "npm run publish:market"
continue-on-error: true