From 43459b778fae5d1534a575a4fb9b30c1a5e58092 Mon Sep 17 00:00:00 2001 From: Raymond Wang Date: Mon, 24 Oct 2022 20:55:17 -0700 Subject: [PATCH] enable firebase previews for pr --- .firebaserc | 1 + .github/workflows/main.yml | 16 ++++------------ .github/workflows/preview.yml | 20 ++++++++++++++++++++ firebase.json | 10 ++++++++++ 4 files changed, 35 insertions(+), 12 deletions(-) create mode 100644 .firebaserc create mode 100644 .github/workflows/preview.yml create mode 100644 firebase.json diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/.firebaserc @@ -0,0 +1 @@ +{} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ee6f199..4966b68 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,13 +6,6 @@ name: build-page-branch on: push: branches: [main] - # The below rule invokes when ANY pull request is made to main - # This is DANGEROUS and can allow for malicious behavior - # pull_request: - # branches: [main] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: @@ -20,19 +13,18 @@ jobs: build: # The type of runner that the job will run on runs-on: ubuntu-latest - # Use production environment specified in GitHub settings - environment: production # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v2 - - uses: actions/setup-node@v3.0.0 + - uses: actions/setup-node@v3 + with: + node-version: 16 # Builds the react site for github pages - name: Build Static Pages run: | - npm i - rm .gitignore + npm ci npm run build mv CNAME build/public mv build/public docs diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml new file mode 100644 index 0000000..48bb221 --- /dev/null +++ b/.github/workflows/preview.yml @@ -0,0 +1,20 @@ +name: deploy-preview + +on: pull_request + +jobs: + build_and_preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v3 + with: + node-version: 16 + - run: | + npm ci + npm run build + - uses: FirebaseExtended/action-hosting-deploy@v0 + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}" + projectId: ieeeucsd-org diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..5165ace --- /dev/null +++ b/firebase.json @@ -0,0 +1,10 @@ +{ + "hosting": { + "public": "build/public", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ] + } +}