Skip to content

Commit

Permalink
Update mongodb-install-test.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
muratugureminoglu authored Jan 30, 2025
1 parent 3b3fd73 commit 23c2f23
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/mongodb-install-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,23 @@ jobs:
uses: actions/checkout@v4

- name: Make script executable
run: chmod +x install_mongodb.sh
run: |
wget https://raw.githubusercontent.com/ant-media/Scripts/3b3fd732613f2e234847231ff2b4c0e36d0440f1/install_mongodb.sh
ls -alh
- name: Run MongoDB installation script
run: sudo ./mongodb-install.sh --auto-create
run: bash ./install_mongodb.sh --auto-create

- name: Verify MongoDB service
run: |
sudo systemctl restart mongod
sudo systemctl enable mongod
sleep 5
systemctl is-active mongod || (echo "MongoDB failed to start" && exit 1)
- name: Test MongoDB authentication
run: |
echo 'show dbs' | mongosh --username "$(grep 'MongoDB username:' mongodb-install.sh | awk '{print $3}')" --password "$(grep 'MongoDB password:' mongodb-install.sh | awk '{print $3}')" --authenticationDatabase admin || (echo "Authentication failed" && exit 1)
USERNAME=$(cat /tmp/mongo_credentials.txt | awk '{print $3}' | head -1)
PASSWORD=$(cat /tmp/mongo_credentials.txt | awk '{print $3}' | tail -1)
echo "Testing login with user: $USERNAME"
echo "show dbs" | mongosh --username "$USERNAME" --password "$PASSWORD" --authenticationDatabase admin || (echo "Authentication failed" && exit 1)

0 comments on commit 23c2f23

Please sign in to comment.