-
Notifications
You must be signed in to change notification settings - Fork 35
32 lines (27 loc) · 1.51 KB
/
mongodb-clone.yml
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
name: Restore Prod DB into Staging
on: [workflow_dispatch]
jobs:
mongo-clone-action:
runs-on: ubuntu-latest
name: Restore Prod DB into Staging
steps:
- name: Install Mongo Tools
run : |
wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | gpg --dearmor | sudo tee /usr/share/keyrings/mongodb.gpg > /dev/null
echo "deb [ arch=amd64 signed-by=/usr/share/keyrings/mongodb.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
sudo apt update
sudo apt install mongodb-database-tools
mongodump --version
mongorestore --version
shell: bash
- name: "Dump Production database"
shell: bash
run: mongodump --uri="${{ secrets.DB_PRODUCTION_CONNECTION_STRING }}"
- name: "Restore Staging database collection: aiidprod"
run: mongorestore ${{ secrets.DB_STAGING_CONNECTION_STRING }}/aiidprod ./dump/aiidprod --drop --noOptionsRestore
- name: "Restore Staging database collection: translations"
run: mongorestore ${{ secrets.DB_STAGING_CONNECTION_STRING }}/translations ./dump/translations --drop --noOptionsRestore
- name: "Restore Staging database collection: history"
run: mongorestore ${{ secrets.DB_STAGING_CONNECTION_STRING }}/history ./dump/history --drop --noOptionsRestore
- name: Trigger Staging Netlify build
run: curl -X POST -d {} ${{ secrets.NETLIFY_BUILD_STAGING_URL }}