supercharge / mongodb-github-action

Use MongoDB in GitHub Actions
MIT License
222 stars 46 forks source link

MongoServerError: Authentication failed. #54

Closed tar-aldev closed 9 months ago

tar-aldev commented 10 months ago

I am following the docs and I've set MONGODB_USERNAME and MONGODB_PASSWORD in github actions -> secrets. yaml file for workflow looks like this

env:
  MONGODB_USERNAME: ${{ secrets.MONGODB_USERNAME }}
  MONGODB_PASSWORD: ${{ secrets.MONGODB_PASSWORD }}

setup-mongodb:
    timeout-minutes: 10
    runs-on: ubuntu-latest
    steps:
      - name: MongoDB in GitHub Actions
        uses: supercharge/mongodb-github-action@v1.10.0
        with:
          mongodb-username: ${{env.MONGODB_USERNAME}}
          mongodb-password: ${{env.MONGODB_PASSWORD}}
          mongodb-db: test

When running it I see

Starting single-node instance, no replica set
    - port [27017]
    - version [latest]
    - database [test]
    - credentials [***:***]

And then this

Waiting for MongoDB to accept connections
  ]0;mongosh mongodb://<credentials>@127.0.0.1:27017/?***&serverSelectionTimeoutMS=2000MongoServerError: Authentication failed.

Any idea what's going on?

marcuspoehls commented 10 months ago

@tar-aldev Hey Alex, that’s strange. Did you try to hard-code a value for mongodb-username and mongodb-password to ensure the values show up correctly in the logs? It’s possible that credentials injected from GitHub secrets are obfuscated in the logs of GitHub Actions (to not expose sensitive data)

env:
  MONGODB_USERNAME: ${{ secrets.MONGODB_USERNAME }}
  MONGODB_PASSWORD: ${{ secrets.MONGODB_PASSWORD }}

setup-mongodb:
    timeout-minutes: 10
    runs-on: ubuntu-latest
    steps:
      - name: MongoDB in GitHub Actions
        uses: supercharge/mongodb-github-action@v1.10.0
        with:
          mongodb-username: hardcoded-value
          mongodb-password: your-password
          mongodb-db: test
tar-aldev commented 9 months ago

Sorry for late feedback. We moved to another solution for now, so I'll close the issue for now. If we come back and still can't make it work I'll reopen the issue.

marcuspoehls commented 9 months ago

@tar-aldev Hi Alex, thanks for the heads up 👍🙂