Comments (7)
@jorlugaqui @kibertoad @biodrone Iโve tagged a new release version 1.7.0
that is now available in the GitHub Actions marketplace containing the MongoDB authentication feature ๐
from mongodb-github-action.
Just used it in my project, working like a dream :)
from mongodb-github-action.
@jorlugaqui Hey Jorge, thank you for your feature request!
Can you please help me understand how youโre injecting the MongoDB authentication credentials into your testing environment? Are you reading the values from environment variables and use them to connect to MongoDB? Or do you have hard-coded values in a configuration file in your app?
from mongodb-github-action.
Hi @marcuspoehls.
I'm not sure if by testing environment
you mean the environment created by GitHub Actions or my local testing environment. So, I'll share both.
Local environment
I'm reading the values from environment variables and I use them to connect to the MongoDB server:
DB_HOST = os.environ.get('DB_HOST', 'localhost')
DB_NAME = os.environ.get('DB_NAME', '')
DB_USER = os.environ.get('DB_USER', '')
DB_PASSWORD = os.environ.get('DB_PASSWORD', '')
With values being injected via docker-compose like:
mongo:
image: mongo
restart: always
...
environment:
MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
api:
...
environment:
...
DB_NAME: ${DB_NAME}
DB_HOST: ${DB_HOST}
DB_USER: ${MONGO_INITDB_ROOT_USERNAME}
DB_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
GitHub actions' environment
For now, I'm using hardcoded values, but when the moment comes, I'll switch to secrets.
name: Run the API and Postman's tests
...
env:
FLASK_ENV: development
API_HOST: 0.0.0.0
FLASK_APP: main.py
DB_NAME: ahm
DB_HOST: localhost
CI: true
How I'm imagining the feature
It will be our responsibility as developers to handle how the values will get into the workflow file. For instance, I could have a step defined like:
- name: Start MongoDB ${{ matrix.mongodb-version }}
uses: supercharge/[email protected]
with:
mongodb-version: ${{ matrix.mongodb-version }}
env:
MONGO_INITDB_ROOT_USERNAME: foo
MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.password }}
One value hardcoded, one value coming from the secrets. The important thing will be that if these two variables are present, we could start the container with the -e
flag like :
docker run -d --network some-network --name some-mongo \
-e MONGO_INITDB_ROOT_USERNAME=$MONGO_INITDB_ROOT_USERNAME \
-e MONGO_INITDB_ROOT_PASSWORD=$MONGO_INITDB_ROOT_PASSWORD \
mongo
And therefore, achieve the "out of the box" authentication mechanism, which should be sufficient for a CI environment.
Let me know your thoughts.
from mongodb-github-action.
@marcuspoehls Are there still plans to implement this? I'm trying to setup Mongo in GA with auth, and there doesn't seem to be an easy way to do so currently :)
from mongodb-github-action.
@kibertoad Hey Igor, thank you for your patience. Iโm in for this feature. Do you want to PR it?
from mongodb-github-action.
Awesome!
from mongodb-github-action.
Related Issues (20)
- Connection timeout HOT 15
- Could you release major version(s) of your GitHub action? HOT 4
- How to restart mongo after adding users? HOT 6
- Would you be interested in a Windows version? HOT 2
- MongoDB 6.0 contains breaking changes that make the setup action fail HOT 3
- [BUG] Action does not fail in case of missing image HOT 13
- How can i add/implement health check using this approach? HOT 1
- `mongo` and `mongosh` disappeared? HOT 15
- How can I Restore Dump from external location HOT 3
- mongoimport command not found HOT 2
- Reaching Docker Hub limit HOT 6
- Cannot connect to mongodb from Springboot HOT 2
- Add action typing HOT 4
- Mongodb tools HOT 1
- Please update v1 tag to point to newest version HOT 2
- single-instance can complete before ready to accept connections HOT 1
- How do I bind to all available interfaces? HOT 2
- tags and releases HOT 2
- MongoServerError: Authentication failed. HOT 3
- Authentication failed. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongodb-github-action.