Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore IDE files.
.idea
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ GitHub Action to take a database dump from a platform.sh site and copy the dump
platformsh_relationship: 'database' # optional. specify if the project has multiple databases.
platformsh_app: 'api' # optional. specify if the project has multiple apps.
aws_s3_bucket: 'bucket-name' # required.
aws_s3_directory: 'my-directory'
db_dump_filename_base: 'sitename-db-dump'
env:
PLATFORMSH_CLI_TOKEN: ${{ secrets.PLATFORMSH_CLI_TOKEN }} # required.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ inputs:
description: 'Filename for the database dump. A timestamp will be appended after it.'
required: false
default: 'db-dump'
aws_s3_directory:
description: 'A directory within the S3 bucket with no proceeding / to copy the file to.'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
Expand Down
9 changes: 8 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,11 @@ else
fi
fi

aws s3 cp "$FILENAME".sql.gz s3://"$INPUT_AWS_S3_BUCKET"
if [ -z "${INPUT_AWS_S3_DIRECTORY}" ] ]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not familiar enough with how aws_s3_directory in config is translated into environment var INPUT_AWS_S3_DIRECTORY, but if that is how it works, then the code looks sane and clean.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I forget where I've found it before and a quick search didn't turn much up, but I'm following the pattern used elsewhere in this repo.

Good eye on the naming difference though. 🦅

@adamzimmermann adamzimmermann May 25, 2022

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to use this, can you point the GH Action to this branch to give this a spin, then once we confirm it works for you, we can merge it?

- uses: chromatichq/db-backup-sync-action@sync-to-subfolder

I think this will do the trick. 🤞🏼

then
# No directory was supplied, copy the file to the root of the bucket.
aws s3 cp "$FILENAME".sql.gz s3://"$INPUT_AWS_S3_BUCKET"
else
# A directory was supplied, so copy the file to it.
aws s3 cp "$FILENAME".sql.gz s3://"$INPUT_AWS_S3_BUCKET"/"$INPUT_AWS_S3_FOLDER"
fi