mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-08 03:20:12 +08:00
feat: add mongo dump script, require ci checks before deployment (#89)
feat: add mongo dump script, require ci checks before deployment
This commit is contained in:
4 files changed
+37
-3
No files matched your search
@@ -15,7 +15,7 @@ jobs:
|
|||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
build:
|
build:
|
||||||
# needs: ci-checks
|
needs: ci-checks
|
||||||
uses: ./.github/workflows/build.yml
|
uses: ./.github/workflows/build.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ jobs:
|
|||||||
uses: mattzcarey/code-review-gpt@v0.1.4-alpha
|
uses: mattzcarey/code-review-gpt@v0.1.4-alpha
|
||||||
with:
|
with:
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
MODEL: 'gpt-4'
|
MODEL: 'gpt-3.5-turbo'
|
||||||
GITHUB_TOKEN: ${{ github.token }}
|
GITHUB_TOKEN: ${{ github.token }}
|
||||||
|
|
||||||
build:
|
build:
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ jobs:
|
|||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
build:
|
build:
|
||||||
# needs: ci-checks
|
needs: ci-checks
|
||||||
uses: ./.github/workflows/build.yml
|
uses: ./.github/workflows/build.yml
|
||||||
secrets: inherit
|
secrets: inherit
|
||||||
|
|
||||||
|
|||||||
@@ -29,4 +29,38 @@ down() {
|
|||||||
docker compose -f docker-compose.testing.yml down
|
docker compose -f docker-compose.testing.yml down
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dump() {
|
||||||
|
# Define service name and dump directory name
|
||||||
|
SERVICE_NAME="db"
|
||||||
|
DUMP_NAME="mongodump-$(date --iso).archive"
|
||||||
|
CONTAINER_ID=$(docker compose ps -q $SERVICE_NAME)
|
||||||
|
|
||||||
|
# Fetch credentials from Docker environment variables
|
||||||
|
MONGO_URL=$(docker compose exec -T backend printenv MONGO_URL)
|
||||||
|
echo mongo uri: $MONGO_URL
|
||||||
|
|
||||||
|
# Dump MongoDB data using credentials
|
||||||
|
docker compose exec -T $SERVICE_NAME sh -c "mongodump --gzip --archive=/tmp/$DUMP_NAME -d odyssey-test" &&
|
||||||
|
|
||||||
|
# Copy the dump from the container to the host
|
||||||
|
# Note: You will need to know the exact container name for this step
|
||||||
|
docker cp ${CONTAINER_ID}:/tmp/$DUMP_NAME . &&
|
||||||
|
|
||||||
|
echo "MongoDB data dumped successfully."
|
||||||
|
}
|
||||||
|
|
||||||
|
restore() {
|
||||||
|
# Define service name and dump directory name
|
||||||
|
SERVICE_NAME="db"
|
||||||
|
DUMP_NAME=$1
|
||||||
|
CONTAINER_ID=$(docker compose ps -q $SERVICE_NAME)
|
||||||
|
|
||||||
|
# Copy the dump from the host to the container
|
||||||
|
docker cp $DUMP_NAME ${CONTAINER_ID}:/tmp &&
|
||||||
|
|
||||||
|
# Dump MongoDB data using credentials
|
||||||
|
docker compose exec -T $SERVICE_NAME sh -c "mongorestore --gzip --archive=/tmp/$DUMP_NAME" &&
|
||||||
|
|
||||||
|
echo "MongoDB data dumped successfully."
|
||||||
|
}
|
||||||
$@
|
$@
|
||||||
Reference in new issue
Block a user