Skip to content

Commit ba830d5

Browse files
Create firebase-deploy.yml
1 parent 91aa79d commit ba830d5

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/firebase-deploy.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Deploy Firebase
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build_and_deploy:
10+
runs-on: ubuntu-latest
11+
env:
12+
NODE_OPTIONS: --max_old_space_size=4096
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v3
16+
17+
- name: Install Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: "18"
21+
22+
- name: Install dependencies with legacy peer deps
23+
run: npm install --legacy-peer-deps
24+
25+
- name: Install js-yaml for Firebase Tools
26+
run: npm install js-yaml --save-dev --legacy-peer-deps
27+
28+
- name: Install firebase-tools locally
29+
run: npm install firebase-tools --save-dev --legacy-peer-deps
30+
31+
- name: Update Browserslist database
32+
run: npx update-browserslist-db@latest --force || true
33+
34+
- uses: actions/cache@v2
35+
with:
36+
path: |
37+
~/.npm
38+
./node_modules
39+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
40+
restore-keys: |
41+
${{ runner.os }}-node-
42+
43+
- name: Install dependencies and build project
44+
run: npm run build --legacy-peer-deps
45+
env:
46+
CI: true
47+
48+
- name: Deploy to Firebase
49+
run: firebase deploy --token ${{ secrets.FIREBASE_SERVICE_ACCOUNT_AITL_MASTER }}
50+
51+
- name: Send Discord notification on success or failure
52+
if: always()
53+
run: |
54+
if [ "${{ job.status }}" == "success" ]; then
55+
STATUS=":white_check_mark: Build succeeded!"
56+
else
57+
STATUS=":x: Build failed!"
58+
fi
59+
60+
PAYLOAD=$(jq -n \
61+
--arg status "$STATUS" \
62+
--arg repository "${{ github.repository }}" \
63+
--arg ref_name "${{ github.ref_name }}" \
64+
--arg workflow "${{ github.workflow }}" \
65+
--arg sha "${{ github.sha }}" \
66+
'{
67+
content: "\($status)\nRepository: **\($repository)**\nBranch: **\($ref_name)**\nPipeline: **\($workflow)**\nCommit: `\($sha)`"
68+
}'
69+
)
70+
71+
curl -H "Content-Type: application/json" \
72+
-X POST \
73+
-d "$PAYLOAD" \
74+
https://discord.com/api/webhooks/1240996154527711312/G0qV8eX4jn7nRoujhbqrx2TrjZJzDWO9pONiymjL2mzVDVeYqXtDRLbSGb-tA_oZ2jcz
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)