Skip to content

Build and deploy to Netlify #273

Build and deploy to Netlify

Build and deploy to Netlify #273

Workflow file for this run

name: Build and deploy to Netlify
on:
workflow_dispatch:
inputs:
site_target:
description: 'Deploy to development or production Reports site? (must deploy to development first)'
required: true
default: 'dev'
type: choice
options:
- dev
- prod
push:
tags:
- '*'
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install python packages
run: |
pip install -r requirements.txt
- name: Install node packages
run: npm install
working-directory: website
- uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
# Run data ----
- name: Run report data
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && inputs.site_target == 'dev')}}
working-directory: reports
run: |
make parameters
make data
# copy data ----
- name: Copy development report data
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && inputs.site_target == 'dev')}}
run: |
gsutil -m rsync -r reports/outputs/ gs://test-calitp-reports-data/report_gtfs_schedule/
- name: Copy production report data
if: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && inputs.site_target == 'prod')}}
run: |
gsutil -m rsync -r gs://test-calitp-reports-data/report_gtfs_schedule/ gs://calitp-reports-data/report_gtfs_schedule/
gsutil -m rsync -r gs://calitp-reports-data/report_gtfs_schedule/ reports/outputs/
# build ----
- name: Build
run: npm run build
working-directory: website
# deploy ----
- name: Deploy development to Netlify
if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') || (github.event_name == 'workflow_dispatch' && inputs.site_target == 'dev')}}
run: |
npm install netlify-cli
netlify deploy --site=cal-itp-reports --dir=./website/build --alias=test
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- name: Deploy production to Netlify
if: ${{ (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'workflow_dispatch' && inputs.site_target == 'prod')}}
run: |
npm install netlify-cli
netlify deploy --site=cal-itp-reports --dir=./website/build --prod
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}