-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(ci): backup aws audio pronunciations
- Loading branch information
Showing
4 changed files
with
95 additions
and
1 deletion.
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,42 @@ | ||
name: Backup AWS Audio Pronunciations | ||
|
||
on: | ||
schedule: | ||
# Backs up AWS audio pronunciations every Sunday at 12:00 AM UTC | ||
- cron: '0 0 * * 0' | ||
|
||
on: | ||
push | ||
|
||
env: | ||
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
DROPBOX_TOKEN: ${{ secrets.DROPBOX_TOKEN }} | ||
DIR: aws_pronunciations | ||
|
||
jobs: | ||
backup_aws: | ||
name: Backup AWS | ||
# https://github.com/actions/checkout/issues/440#issuecomment-778899551 | ||
runs-on: ubuntu-18.04 | ||
|
||
strategy: | ||
matrix: | ||
python-version: [3.8] | ||
|
||
steps: | ||
- name: Skipping steps | ||
run: echo "Skipping steps" | ||
# Skipping the following steps to prioritize using AWS S3 Glacier | ||
|
||
# - name: Git checkout files and create aws db directory | ||
# uses: actions/checkout@v2 | ||
# - name: Set up network configurations | ||
# run: sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf | ||
# - name: Create temporary directory | ||
# run: mkdir $DIR | ||
# - name: Dump the AWS audio pronunciations | ||
# run: aws s3 cp $AWS_S3_BUCKET ./$DIR --recursive --storage-class STANDARD --force-glacier-transfer | ||
# - name: Upload to Dropbox | ||
# run: ./scripts/aws_sync.sh $DROPBOX_TOKEN |
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 |
---|---|---|
|
@@ -134,4 +134,8 @@ dist | |
.pnp.* | ||
|
||
# Cypress | ||
./cypress/ | ||
./cypress/ | ||
|
||
# Backup directories | ||
./igbo_api_db | ||
./aws_pronunciations |
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,48 @@ | ||
#!/usr/bin/env bash | ||
|
||
#Get current date | ||
NOW="$(date +'%m-%d-%Y_%H-%M')" | ||
|
||
# Path to a temporary directory | ||
DIR=aws_pronunciations | ||
|
||
# Name of the database | ||
DB_NAME=aws_igbo_api | ||
|
||
# Name of the compressed file | ||
FILE="${DB_NAME}_${NOW}.tar.gz" | ||
|
||
function aws_compress | ||
{ | ||
|
||
# Compress | ||
tar -zcvf $FILE $DIR | ||
|
||
# Remove the temporary database dump directory | ||
rm -fr $DIR | ||
} | ||
|
||
aws_compress | ||
|
||
readonly TOKEN=$1 | ||
readonly DIR= | ||
BASENAME=$(basename $FILE) | ||
if [ -f "$FILE" ]; then | ||
# upload file to dropbox | ||
CMD="upload $DIR/$BASENAME" | ||
HTTP_CODE=$(curl -X POST -sL -w "%{http_code}" --output /dev/null https://content.dropboxapi.com/2/files/upload \ | ||
--header "Authorization: Bearer $TOKEN" \ | ||
--header "Dropbox-API-Arg: {\"path\": \"$DIR/$BASENAME\",\"mode\": \"add\",\"autorename\": true,\"mute\": false,\"strict_conflict\": false}" \ | ||
--header "Content-Type: application/octet-stream" \ | ||
--data-binary @$FILE) | ||
fi | ||
echo $CMD | ||
echo "Response code => $HTTP_CODE" | ||
|
||
if [ $HTTP_CODE != "200" ]; then | ||
echo "🔴 Backup failed" | ||
exit 1 | ||
else | ||
echo "✅ Backup successful" | ||
exit 0 | ||
fi |