feat: preview action update and typography #155
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create and deploy a build on all pull requests | |
name: PR Preview | |
on: | |
# use pull_request_target so that secrets accessible from fork | |
pull_request: | |
# Trigger when labels are changed or more commits added to a PR that contains labels | |
types: [labeled, synchronize] | |
# TODO - rever back when working | |
# # use pull_request_target so that secrets accessible from fork | |
# pull_request_target: | |
# # Trigger when labels are changed or more commits added to a PR that contains labels | |
# types: [labeled, synchronize] | |
jobs: | |
build_and_preview: | |
# NOTE - as we are going to check out and build from forks we also need to add manual | |
# check that malicious code has not been inserted. This is handled by manually labelling the PR | |
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests | |
if: contains(github.event.pull_request.labels.*.name, 'build-preview ✅') | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# pull the repo from the pull request source, not the default local repo | |
ref: ${{ github.event.pull_request.head.sha }} | |
############################################################################# | |
# Node Modules | |
# Manually restore any previous cache to speed install | |
# As immutable install will not change cache only save new cache if not hit | |
# Uses fine-grained methods from https://github.com/actions/cache | |
############################################################################# | |
- name: Enable Corepack | |
run: corepack enable | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22.x | |
cache: "yarn" | |
- uses: actions/cache/restore@v4 | |
id: cache | |
with: | |
path: ./.yarn/cache | |
key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-modules-yarn-v1 | |
- name: Install node modules | |
run: yarn install --immutable | |
- uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
path: ./.yarn/cache | |
key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('yarn.lock') }} | |
- name: Populate Config | |
run: echo $FIREBASE_CONFIG_JSON > maths-club-app/src/environments/firebaseConfig.json | |
env: | |
FIREBASE_CONFIG_JSON: ${{secrets.FIREBASE_CONFIG_JSON}} | |
- name: Build and Copy | |
run: cd maths-club-app && npm run build:prod | |
- uses: FirebaseExtended/action-hosting-deploy@v0 | |
with: | |
repoToken: "${{ secrets.GITHUB_TOKEN }}" | |
# the details of the service account need to be populated to github secrets | |
# these must match the target projectId account | |
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}" | |
expires: 30d | |
projectId: sami-maths-club | |
entryPoint: "./maths-club-app" |