FOR GITHUB
To connect MongoDB Atlas GraphQL to GitHub, you can use a CI/CD pipeline in GitHub Actions to automate the deployment of your GraphQL schema changes to Atlas. Here are the general steps to set up the integration:
-
Create a new GitHub account if you don’t already have one.
-
Create a new GitHub repository for your MongoDB Atlas GraphQL project.
-
Create a GitHub Actions workflow configuration file in the “.github/workflows” directory of your repository. This file should contain the necessary build and deployment steps for your MongoDB Atlas GraphQL schema. Here’s an example configuration file that deploys a GraphQL schema to Atlas:
name: Deploy GraphQL schema to MongoDB Atlas
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Deploy GraphQL schema to Atlas
env:
ATLAS_USERNAME: ${{ secrets.ATLAS_USERNAME }}
ATLAS_PASSWORD: ${{ secrets.ATLAS_PASSWORD }}
ATLAS_PROJECT_ID: ${{ secrets.ATLAS_PROJECT_ID }}
ATLAS_GRAPHQL_ENDPOINT: ${{ secrets.ATLAS_GRAPHQL_ENDPOINT }}
run: npx graphql-schema-push \
--config config.yml \
--dry-run false \
--verbose true
-
Add the necessary secrets to your GitHub repository by navigating to the “Settings” page and selecting the “Secrets” tab. You’ll need to add the following secrets:
-
ATLAS_USERNAME
: the username for your MongoDB Atlas account -
ATLAS_PASSWORD
: the password for your MongoDB Atlas account -
ATLAS_PROJECT_ID
: the ID of your MongoDB Atlas project -
ATLAS_GRAPHQL_ENDPOINT
: the endpoint URL for your MongoDB Atlas GraphQL API
You can find your Atlas project ID and GraphQL endpoint URL in the “Settings” tab of your MongoDB Atlas project.
-
-
Commit and push your GitHub Actions workflow configuration file to your GitHub repository.
-
Trigger a pipeline in GitHub Actions by pushing a new commit to your repository. GitHub Actions will execute the build and deployment steps defined in your workflow configuration file and deploy your GraphQL schema to MongoDB Atlas.
By following these steps, you can connect MongoDB Atlas GraphQL to GitHub and automate the deployment of your schema changes to Atlas.
FOR GITLAB
To connect MongoDB Atlas GraphQL to GitLab, you can use a CI/CD pipeline in GitLab CI/CD to automate the deployment of your GraphQL schema changes to Atlas. Here are the general steps to set up the integration:
-
Create a new GitLab account if you don’t already have one.
-
Create a new GitLab repository for your MongoDB Atlas GraphQL project.
-
Create a GitLab CI/CD pipeline configuration file in the root directory of your repository. This file should contain the necessary build and deployment steps for your MongoDB Atlas GraphQL schema. Here’s an example configuration file that deploys a GraphQL schema to Atlas:
image: node:12
stages:
- deploy
deploy:
stage: deploy
script:
- npm install
- npx graphql-schema-push \
--config config.yml \
--dry-run false \
--verbose true
environment:
name: production
only:
- main
-
Add the necessary secrets to your GitLab repository by navigating to the “Settings” page and selecting the “CI/CD” tab. You’ll need to add the following secrets:
-
ATLAS_USERNAME
: the username for your MongoDB Atlas account -
ATLAS_PASSWORD
: the password for your MongoDB Atlas account -
ATLAS_PROJECT_ID
: the ID of your MongoDB Atlas project -
ATLAS_GRAPHQL_ENDPOINT
: the endpoint URL for your MongoDB Atlas GraphQL API
You can find your Atlas project ID and GraphQL endpoint URL in the “Settings” tab of your MongoDB Atlas project.
-
-
Commit and push your GitLab CI/CD pipeline configuration file to your GitLab repository.
-
Trigger a pipeline in GitLab CI/CD by pushing a new commit to your repository. GitLab CI/CD will execute the build and deployment steps defined in your pipeline configuration file and deploy your GraphQL schema to MongoDB Atlas.
By following these steps, you can connect MongoDB Atlas GraphQL to GitLab and automate the deployment of your schema changes to Atlas.