From 85bf9f5dd49810aeffa50e7a81f687062dc542c5 Mon Sep 17 00:00:00 2001 From: LoneRifle Date: Thu, 5 Sep 2024 11:46:14 +0800 Subject: [PATCH] chore(ci): reset users midnight utc --- .github/workflows/reset-users.yml | 26 ++++++++++++++++++++++++++ bin/reset-users.mongodb.js | 4 ++++ 2 files changed, 30 insertions(+) create mode 100644 .github/workflows/reset-users.yml create mode 100644 bin/reset-users.mongodb.js diff --git a/.github/workflows/reset-users.yml b/.github/workflows/reset-users.yml new file mode 100644 index 0000000..7e2464b --- /dev/null +++ b/.github/workflows/reset-users.yml @@ -0,0 +1,26 @@ +name: Reset users + +on: + workflow_dispatch: + schedule: + # * is a special character in YAML so you have to quote this string + - cron: '0 0 * * *' +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout this repo + uses: actions/checkout@v4 + - name: 🍃 Install mongosh + run: | + sudo apt-get update + sudo apt-get install -y wget gnupg + wget -qO - https://www.mongodb.org/static/pgp/server-6.0.asc | sudo apt-key add - + echo "deb [ arch=amd64,arm64 ] 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-get update + sudo apt-get install -y mongodb-mongosh + - name: Reset mongo + env: + DB_URI: ${{ secrets.DB_URI }} + run: | + mongosh -f bin/reset-users.mongodb.js $DB_URI diff --git a/bin/reset-users.mongodb.js b/bin/reset-users.mongodb.js new file mode 100644 index 0000000..46dc309 --- /dev/null +++ b/bin/reset-users.mongodb.js @@ -0,0 +1,4 @@ +/* eslint-disable */ + +db.sessions.deleteMany({ }) +db.users.deleteMany({ })