-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
sync-assets.sh
executable file
·39 lines (31 loc) · 985 Bytes
/
sync-assets.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
set -eu
# "azcopy" command, defaults to searching for it in the PATH
: "${AZCOPYCMD:=$(which azcopy)}"
echo "Using azcopy in $AZCOPYCMD"
# Ensure azcopy is installed
"$AZCOPYCMD" --version
# Check required env vars: $ASSETS, $CONTAINER, $AZURE_STORAGE_ACCOUNT
if [ -z "$ASSETS" ]; then
echo "\$ASSETS is empty"
exit 1
fi
if [ -z "$CONTAINER" ]; then
echo "\$CONTAINER is empty"
exit 1
fi
if [ -z "$AZURE_STORAGE_ACCOUNT" ]; then
echo "\$AZURE_STORAGE_ACCOUNT is empty"
exit 1
fi
echo "Syncing with: https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${CONTAINER}"
# Sync all folders
for asset in $ASSETS; do
# Ensure the asset exists and it's a folder
if [ -d "$asset" ]; then
# Sync the folder
"$AZCOPYCMD" sync "$asset" https://${AZURE_STORAGE_ACCOUNT}.blob.core.windows.net/${CONTAINER}/${asset} --recursive --delete-destination=true
else
echo "$asset doesn't exist or it's not a folder"
fi
done