44 lines
1.5 KiB
YAML
44 lines
1.5 KiB
YAML
name: Test Gitea Actions with Service Containers
|
|
on: push
|
|
|
|
env:
|
|
# Global Env Variables readable in all jobs of this workflow
|
|
MONGODB_CLUSTER_ADDRESS: mongodb # The network alias name of the mongodb docker service container
|
|
# Env Variables which the Example JS App will access
|
|
MONGODB_USERNAME: root
|
|
MONGODB_PASSWORD: supersecretpassword
|
|
MONGODB_DB_NAME: actionsenvironment
|
|
PORT: 8080
|
|
|
|
jobs:
|
|
build:
|
|
# Job will execute the Steps inside a 'node:latest' docker container
|
|
container:
|
|
image: node:latest
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
# Before running the Steps of this job...
|
|
# The runner will spawm a second container 'mongodb' using the mongo:latest image with some db settings
|
|
# The node container and the mongodb container will be in a new temporary docker bridge network
|
|
mongodb:
|
|
image: mongo:latest
|
|
# Docker related container env Variables for the mongo image (JS App will not have these variables)
|
|
env:
|
|
MONGO_INITDB_DATABASE: actionsenvironment
|
|
MONGO_INITDB_ROOT_USERNAME: root
|
|
MONGO_INITDB_ROOT_PASSWORD: supersecretpassword
|
|
|
|
steps:
|
|
- name: Install NodeJS
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '18'
|
|
- name: Get Code
|
|
uses: actions/checkout@v3
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
- name: Run server
|
|
run: npm start & npx wait-on http://127.0.0.1:$PORT
|
|
- name: Run tests
|
|
run: npm test
|