Skip to content

WIP: Discover

WIP: Discover #3568

Workflow file for this run

name: Build, Test, Deploy
on: [push, pull_request]
jobs:
#########################
## Site Build & Testing
#########################
build-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Examine Node
run: |
node -v
npm -v
- name: Determine Lockfile
id: lockfile
run: |
if [[ -f "package-lock.json" || -f "npm-shrinkwrap.json" ]]; then
echo "::set-output name=exists::true"
else
echo "::set-output name=exists::false"
fi
- name: Install - Lockfile
if: steps.lockfile.outputs.exists == 'true'
run: |
npm ci --no-optional
- name: Install - No Lockfile
if: steps.lockfile.outputs.exists == 'false'
run: |
npm install
- name: Install CLI dependencies
run: |
sudo apt-get update
sudo apt-get install giflib-tools webp ffmpeg
- name: Build and Test
run: |
npm test
npm run build --if-present
env:
CI: true
- name: Upload built state
uses: actions/upload-artifact@v1
with:
name: site
path: public
# Needed for redirect building
- name: Upload firebase.json with redirects
uses: actions/upload-artifact@v1
with:
name: firebase
path: firebase.json
# Needed for functions deploy
- name: Upload search index state
uses: actions/upload-artifact@v1
if: github.ref == 'refs/heads/main'
with:
name: indexes
path: functions/indexes
#########################
## Preview Deploy
#########################
preview:
needs: build-test
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download compiled site
uses: actions/download-artifact@v1
with:
name: site
path: public
- name: Remove firebase.json without redirects
run: |
rm firebase.json
- name: Download firebase.json with redirects
uses: actions/download-artifact@v3
with:
name: firebase
- name: Deploy Hosting Preview
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_CROS_STAGING }}'
expires: 30d
#########################
## Production Deploy
#########################
deploy:
needs: build-test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Download compiled site
uses: actions/download-artifact@v1
with:
name: site
path: public
- name: Remove firebase.json without redirects
run: |
rm firebase.json
- name: Download firebase.json with redirects
uses: actions/download-artifact@v3
with:
name: firebase
- name: Download compiled indexes
uses: actions/download-artifact@v1
with:
name: indexes
path: functions/indexes
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 16
- name: Install functions dependencies
if: github.ref == 'refs/heads/main'
run: |
npm ci --prefix functions
- name: Deploy Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_CROS_STAGING }}'
channelId: live
- name: Deploy Functions
uses: w9jds/[email protected]
with:
args: deploy --only functions
env:
GCP_SA_KEY: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_CROS_STAGING }}