Created
April 25, 2020 14:20
-
-
Save DennisAlund/da799bba6eacbf0ffeb968c8bdaa760d to your computer and use it in GitHub Desktop.
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
name: Backup archive | |
env: | |
BACKUP_BUCKET: "gs://example-prod-backups" | |
FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} | |
on: | |
schedule: | |
# First of every month at some time when your app is least active | |
- cron: "0 3 1 * *" | |
jobs: | |
backup-firestore: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup gcloud environment | |
uses: GoogleCloudPlatform/[email protected] | |
with: | |
project_id: example-prod | |
service_account_key: ${{ secrets.GCLOUD_AUTH_KEY_PROD }} | |
- name: Select project | |
run: gcloud config set project example-prod | |
- name: Export Firestore | |
run: gcloud firestore export ${{ env.BACKUP_BUCKET }}/firestore/$(date '+%Y-%m-%d') --async | |
backup-rtdb: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup gcloud environment | |
uses: GoogleCloudPlatform/[email protected] | |
with: | |
project_id: example-prod | |
service_account_key: ${{ secrets.GCLOUD_AUTH_KEY_PROD }} | |
- name: Select project | |
run: gcloud config set project example-prod | |
- name: Select Firebase project | |
uses: w9jds/[email protected] | |
with: | |
args: use production | |
- name: Generate backup file name | |
run: | | |
echo "::set-env name=BACKUP_FILE::$(date '+%Y-%m-%d').json" | |
- name: Download RTDB data | |
uses: w9jds/[email protected] | |
with: | |
args: database:get --output ${{ env.BACKUP_FILE }} / | |
- name: Upload to Cloud Storage Bucket | |
run: gsutil cp ${{ env.BACKUP_FILE }} ${{ env.BACKUP_BUCKET }}/rtdb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment