Skip to content

Reset Staging Site

Reset Staging Site #6

# Action to allow trigger of the firebase project migration script, used to reset the staging site
# For more info see the script file (/scripts/maintenance/resetStagingSite.ts)
name: Reset Staging Site
on:
# Run weekly on a Sunday at 02:00
schedule:
- cron: '0 0 * * SUN'
# Allow the script to be triggered directly from GitHub
workflow_dispatch:
jobs:
deploy:
name: Reset Staging Site
runs-on: ubuntu-18.04
timeout-minutes: 60
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v3
with:
node-version: 18
- name: Set up Cloud SDK
uses:
google-github-actions/setup-gcloud@master
# skipping setting a service account here as we'll load from json during script
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn config get cacheFolder)"
# Setup yarn 2 cache: https://github.com/actions/cache/blob/main/examples.md#node---yarn
- name: Setup Cache
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install npm dependencies
run: yarn install --immutable
- name: Install global dependencies
run: npm i -g firebase-tools ts-node
- name: Populate service account json
run: echo $ONEARMY_MIGRATOR_SERVICE_ACCOUNT_JSON > config/onearmy-migrator-service-account.json
env:
ONEARMY_MIGRATOR_SERVICE_ACCOUNT_JSON: ${{secrets.ONEARMY_MIGRATOR_SERVICE_ACCOUNT_JSON}}
- name: Run db migration script
run: ts-node --project scripts/tsconfig.json scripts/maintenance/resetStagingSite.ts.ts