This repository has been archived by the owner on Mar 18, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from inthepocket/feature/upload-to-cloud
Add support to upload output to cloud storage/providers
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Pretty log output | ||
function log() { | ||
printf "\\n\\033[1m\\033[34m%s\\033[0m\\n\\n" "[sketchxport-scripts] ${1}" | ||
} | ||
|
||
# @param $1 asset output dir | ||
# @param $2 config output dir | ||
# @param $3 bucket name | ||
function upload_to_gcloud() { | ||
if ! command -v gsutil > /dev/null; then | ||
log "The required gsutil CLI was not found." | ||
fi | ||
|
||
if [ -z "$1" ]; then | ||
log "-> Google Cloud upload error: Parameter 1 was not supplied." | ||
log "You should supply the asset output dir as parameter 1" | ||
exit 1 | ||
fi | ||
if [ -z "$2" ]; then | ||
log "-> Google Cloud upload error: Parameter 2 was not supplied." | ||
log "You should supply the config output dir as parameter 2" | ||
exit 1 | ||
fi | ||
if [ -z "$3" ]; then | ||
log "-> Google Cloud upload error: Parameter 3 was not supplied." | ||
log "You should supply the Google Cloud bucket name as parameter 3 without the gs:// prefix" | ||
exit 1 | ||
fi | ||
|
||
log "⛅️ Uploading to Google Cloud (using bucket: gs://$3)" | ||
|
||
# Upload asset output dir recursively to the provided bucket (in parallell) | ||
gsutil -m cp -r "$1" "gs://$3" && \ | ||
# Upload config output to the provided bucket. | ||
gsutil cp "$2/sketchxport.json" "gs://$3" | ||
} |
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