This is the official GitHub Action for the MongoDB Atlas CLI, published on the GitHub Marketplace
This guide provides getting started instructions for the official Atlas CLI GitHub Action.
This Action allows you to run any Atlas CLI command in your own GitHub workflows. By default, this Action uses the latest version of the Atlas CLI. The version can be configured with the 'version' input parameter, but only the latest version is officially supported.
Before you begin, complete the following prerequisites:
- Configure Atlas CLI API Keys for your organization or project.
- Add the API Keys to the repository secrets.
- Set the environment variables
MONGODB_ATLAS_PUBLIC_API_KEY
andMONGODB_ATLAS_PRIVATE_API_KEY
to the Atlas CLI API Keys you configured. See Atlas CLI Environment Variables for all supported environment variables.
To run CLI commands with this Action you can either use Atlas CLI commands from a bash shell (see Basic workflow below) or use configuration parameters to run predefined workflows. See action.yml for available inputs/outputs.
See test.yml for more examples.
This workflow installs the CLI and prints the CLI version.
on: [push]
name: Atlas CLI Action Sample
jobs:
use-atlas-cli:
runs-on: ubuntu-latest
steps:
- name: Setup AtlasCLI
uses: mongodb/atlas-github-action@v0.2.0
- name: Use AtlasCLI
shell: bash
run: atlas --version # Print Atlas CLI Version
This workflow sets up a project and creates a free cluster. It retrieves the connection string which can be used to connect to the new cluster. Afterwards, it deletes the project and cluster.
on: [push]
name: Atlas CLI Action Sample
env:
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.PUBLIC_API_KEY }}
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.PRIVATE_API_KEY }}
MONGODB_ATLAS_ORG_ID: ${{ secrets.ORG_ID }} # default organisation ID
MONGODB_ATLAS_PROJECT_ID: ${{ secrets.PROJECT_ID }} # default project ID
jobs:
setup:
runs-on: ubuntu-latest
steps:
- name: Setup AtlasCLI and create a project
id: create-project
uses: mongodb/atlas-github-action@v0.2.0
with:
create-project-name: test-setup-project
- name: Run setup
id: setup
uses: mongodb/atlas-github-action@v0.2.0
with:
run-setup: true
project-id: ${{ steps.create-project.outputs.create-project-id }}
cluster-name: test-cluster
username: test-user
password: test-password
- name: Retrieve Connection String
shell: bash
run: |
echo "${{ steps.setup.outputs.connection-string }}"
- name: Teardown
uses: mongodb/atlas-github-action@v0.2.0
with:
delete-project-id: ${{ steps.create-project.outputs.create-project-id }}
delete-cluster-name: test-cluster
This Action supports only Linux runners (e.g. ubuntu-latest).
The Atlas CLI GitHub Action is released under the Apache 2.0 license. See LICENSE.