Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add firebase hosting with ci #54

Merged
merged 21 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading