Skip to content

add mongo db container. #5

add mongo db container.

add mongo db container. #5

Workflow file for this run

name: Deployment (Container)
on:
push:
branches:
- main
- dev
env:
CACHE_KEY: node-deps
MONGODB_DB_NAME: gha-demo
jobs:
test:
environment: testing
runs-on: ubuntu-latest
container:
image: node:16
env:
MONGODB_CONNECTION_PROTOCOL: mongodb
# use the database from the service below.
MONGODB_CLUSTER_ADDRESS: mongodb
# We're using the mongdb server noted below.
MONGODB_USERNAME: root
MONGODB_PASSWORD: example
PORT: 8080
services:
mongodb:
image: mongo
env:
# These are test credentials for the db running in the container, fine
# to expose here.
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
ports:
- 27017:27017
env:

Check failure on line 34 in .github/workflows/deploy.yml

View workflow run for this annotation

GitHub Actions / Deployment (Container)

Invalid workflow file

The workflow is not valid. .github/workflows/deploy.yml (Line: 34, Col: 9): 'env' is already defined
MONGO_INITDB_ROOT_USERNAME: ${{ secrets.MONGODB_USERNAME }}
MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.MONGODB_PASSWORD }}
MONGO_INITDB_DATABASE: ${{ env.MONGODB_DB_NAME }}
steps:
- name: Get Code
uses: actions/checkout@v3
- name: Cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ env.CACHE_KEY }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci
- name: Run server
run: npm start & npx wait-on http://127.0.0.1:$PORT # requires MongoDB Atlas to accept requests from anywhere!
- name: Run tests
run: npm test
- name: Output information
run: |
echo "MONGODB_USERNAME: $MONGODB_USERNAME"
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- name: Output information
env:
PORT: 3000
run: |
echo "MONGODB_DB_NAME: $MONGODB_DB_NAME"
echo "MONGODB_USERNAME: $MONGODB_USERNAME"
echo "${{ env.PORT }}"