Skip to content

Instantly share code, notes, and snippets.

@amitbd1508
Last active March 22, 2019 19:38
Show Gist options
  • Save amitbd1508/c92b8ae4e66a0e7878e7b18e15d99513 to your computer and use it in GitHub Desktop.
Save amitbd1508/c92b8ae4e66a0e7878e7b18e15d99513 to your computer and use it in GitHub Desktop.
Gitlab-Ci pipeline configuration file
#################################
# GitLab Continuous Integration #
#################################
variables:
DEV_ACCOUNT_KEY_FILE: "dev-account-key.json"
DEV_PROJECT_ID: "<Your development project ID>"
DEV_BUCKET: "<Your google cloud bucket eg: gs://your-project-id.appspot.com/>"
PROD_ACCOUNT_KEY_FILE: "prod-account-key.json"
PROD_PROJECT_ID: "<Your production project ID>"
PROD_BUCKET: "<Your google cloud bucket eg: gs://your-project-id.appspot.com/>"
.job_environment_development: &job_environment_development
only:
- firestore-development-backup
.job_environment_production: &job_environment_production
only:
- firestore-production-backup
.job_firestore_backup_template: &job_firestore_backup_template
image: google/cloud-sdk
script:
- cp $KEY key.json; #Copy local file to runner instance
- gcloud auth activate-service-account --key-file=key.json; #Authenticating gcloud
- gcloud config set project $PROJECT_ID; #Selecting project
- echo "Backuping firestore all collection";
- gcloud beta firestore export $BUCKET; #Backup/Export firestore all collection
- echo "Backup complete";
job_backup_development:
<<: *job_firestore_backup_template
<<: *job_environment_development
variables:
PROJECT_ID: $DEV_PROJECT_ID
KEY: $DEV_ACCOUNT_KEY_FILE
BUCKET: $DEV_BUCKET
job_backup_production:
<<: *job_firestore_backup_template
<<: *job_environment_production
variables:
PROJECT_ID: $PROD_PROJECT_ID
KEY: $PROD_ACCOUNT_KEY_FILE
BUCKET: $PROD_BUCKET
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment