-
Notifications
You must be signed in to change notification settings - Fork 15
47 lines (42 loc) · 1.43 KB
/
deploy-hosting.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
# Deploy to Firebase hosting
name: Deploy to Firebase - deploy on push
# only on selected branches
on:
push:
branches: [main, dev, staging]
jobs:
build_and_deploy_to_firebase_hosting:
defaults:
run:
working-directory: ./web
runs-on: ubuntu-latest
environment:
${{ (github.ref == 'refs/heads/main' && 'p0tion-production') ||
(github.ref == 'refs/heads/staging' && 'p0tion-staging') ||
(github.ref == 'refs/heads/dev' && 'p0tion-development') }}
steps:
- uses: actions/checkout@v3
- name: Install deps and build
run: |
echo "${{ secrets.ENV_FILE }}" > ./.env
npm install -g pnpm
npm install -g firebase-tools
pnpm install
pnpm build
- name: Write serviceAccountKey to a JSON file
uses: jsdaniell/[email protected]
with:
name: "./web/serviceAccountKey.json"
json: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
# Conditional deployment based on the target branch
- name: Deploy
run: |
if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
pnpm deploy:prod
elif [[ "${{ github.ref }}" == "refs/heads/dev" ]]; then
pnpm deploy:dev
elif [[ "${{ github.ref }}" == "refs/heads/staging" ]]; then
pnpm deploy:staging
fi
env:
GOOGLE_APPLICATION_CREDENTIALS: ./serviceAccountKey.json