.github/workflows/create-user-mongo-db.yml #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create User Mongo DB | |
on: | |
push: | |
branches: | |
- feat/atlas-mongo-db-gh-action | |
workflow_dispatch: | |
inputs: | |
email: | |
description: where to send the email | |
required: true | |
env: | |
MONGODB_ATLAS_PUBLIC_API_KEY: ${{ secrets.MONGODB_ATLAS_PUBLIC_API_KEY }} | |
MONGODB_ATLAS_PRIVATE_API_KEY: ${{ secrets.MONGODB_ATLAS_PRIVATE_API_KEY }} | |
MONGODB_ATLAS_ORG_ID: '6630fe6c4a18910569ad5e79' | |
MONGODB_ATLAS_PROJECT_ID: 'default' | |
jobs: | |
create-db: | |
runs-on: ubuntu-latest | |
steps: | |
- id: 'generate-db-id' | |
name: 'generate db id' | |
uses: 'yakubique/[email protected]' | |
with: | |
min: 111111 | |
max: 999999 | |
- id: 'generate-db-pw' | |
uses: aammirmirza/[email protected] | |
with: | |
length: 15 | |
- name: Setup AtlasCLI and create a project | |
id: create-project | |
uses: mongodb/[email protected] | |
with: | |
create-project-name: ${{ steps.generate-db-id.outputs.number }} | |
- name: Run setup | |
id: setup | |
uses: mongodb/[email protected] | |
with: | |
run-setup: true | |
project-id: ${{ steps.create-project.outputs.create-project-id }} | |
cluster-name: ${{ steps.generate-db-id.outputs.number }} | |
username: ${{ steps.generate-db-id.outputs.number }} | |
password: ${{ steps.generate-db-pw.outputs.password }} | |
- name: Retrieve Connection String | |
shell: bash | |
run: | | |
echo "${{ steps.setup.outputs.connection-string }}" | |
- name: Send mail | |
uses: dawidd6/action-send-mail@v3 | |
with: | |
server_address: mail.your-server.de | |
server_port: 465 | |
secure: true | |
username: [email protected] | |
password: ${{secrets.MAIL_PASSWORD}} | |
subject: CODE IDP Database Created! ✨ | |
to: ${{ github.event.inputs.email }} | |
from: The friendly code idp bot | |
body: 'Your database has been created! 🎉 Your DB ID and Username is: ${{ steps.generate-db-id.outputs.number }} The Password is: ${{ steps.generate-db-pw.outputs.password }} The connection string is: ${{ steps.setup.outputs.connection-string }}' |