A simple github action to trigger mongoDB database clones via mongodump & mongorestore
It will overwrite any existing target database with the source database.
Trigger manually when needed with workflow_dispatch
.github/workflows/clone-db.yml
name: MongoDB Clone
on: [workflow_dispatch]
jobs:
mongo-clone-action:
runs-on: ubuntu-22.04
name: Clone MongoDB
steps:
- uses: Maggi64/mongo-clone-action@0.3
with:
source: mongodb+srv://<DB_USER>:<DB_PASSWORD>@<DB_HOST>/<SOURCE_DB_NAME>
target: mongodb+srv://<DB_USER>:<DB_PASSWORD>@<DB_HOST>/<TARGET_DB_NAME>
It is highly recommended storing the database user and password via github secrets.
source: ${{ secrets.DB_CONNECT_URI }}/<SOURCE_DB_NAME>
target: ${{ secrets.DB_CONNECT_URI }}/<TARGET_DB_NAME>
https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#on
I created this for my own use only. PRs extending the functionality are welcome and will be reviewed.