Skip to content

Commit

Permalink
Add firebase hosting with ci (#54)
Browse files Browse the repository at this point in the history
* Add firebase hosting with ci

* try fixing build

* update public directory

* fix next export

* remove export thing

* change to unoptimized images

* change build route

* fix public folder possibly

* remove auto generated index

* update public again

* firbease backend setup + better yaml

* add npm ci to backend build

* delete bad casing file

* put back bad casing file

* remove .firebase

* update gitignore

* update build and deploy yaml

* update build script

* small refactor

* update refactor
  • Loading branch information
parth4apple authored Feb 12, 2024
1 parent 2c7c6ae commit 74aa02f
Show file tree
Hide file tree
Showing 14 changed files with 284 additions and 99 deletions.
5 changes: 5 additions & 0 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"projects": {
"default": "pia-dev-60cea"
}
}
50 changes: 50 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Deploy

on:
workflow_call:
inputs:
environment:
required: true
type: string
firebaseProjectId:
required: true
type: string
firebaseHostingChannelId:
required: false
type: string

jobs:
build_and_preview:
name: Build and Deploy
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Create Frontend .env
run: |
cd frontend
touch .env
echo FIREBASE_CONFIG=${{ secrets.FIREBASE_CONFIG }} >> .env
- name: Create Backend .env
run: |
cd backend
touch .env
echo MONGO_URI=${{ secrets.MONGO_URI }} >> .env
echo SERVICE_ACCOUNT_KEY=${{ secrets.SERVICE_ACCOUNT_KEY }} >> .env
echo APP_PORT=${{ secrets.APP_PORT }} >> .env
- name: Build Frontend
run: cd frontend && npm ci && npm run build
- name: Build Backend
run: |
cd backend
npm run build
- name: Deploy to Firebase
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_PIA_DEV_60CEA }}"
projectId: ${{ inputs.firebaseProjectId }}
channelId: ${{ inputs.firebaseHostingChannelId }}
env:
FIREBASE_CLI_EXPERIMENTS: pintags
13 changes: 13 additions & 0 deletions .github/workflows/preview-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Deploy Branch Preview
on:
pull_request:

jobs:
deploy_preview:
name: Deploy Branch Preview
if: "${{ github.event.pull_request.head.repo.full_name == github.repository }}"
uses: ./.github/workflows/build-and-deploy.yml
with:
environment: Preview
firebaseProjectId: pia-dev-60cea
secrets: inherit
15 changes: 15 additions & 0 deletions .github/workflows/staging-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Deploy to Staging
on:
push:
branches:
- main

jobs:
deploy_staging:
name: Deploy to Staging
uses: ./.github/workflows/build-and-deploy.yml
with:
environment: Staging
firebaseProjectId: pia-dev-60cea
firebaseHostingChannelId: live
secrets: inherit
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -128,3 +128,6 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*

# Firebase
.firebase
Loading

0 comments on commit 74aa02f

Please sign in to comment.