Run Poet-App #2
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: Run Poet-App | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'package.json' | |
schedule: | |
- cron: "0 0 * * *" | |
jobs: | |
publish: | |
name: Publish Package | |
runs-on: ubuntu-latest | |
services: | |
mongodb: | |
image: mongo:5.0 | |
ports: | |
- 27017:27017 | |
options: >- | |
--health-cmd="mongo --eval 'db.runCommand({ ping: 1 })'" | |
--health-interval=10s | |
--health-timeout=5s | |
--health-retries=5 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
registry-url: 'https://registry.npmjs.org/' | |
- name: Install dependencies | |
run: npm install | |
- name: Wait for MongoDB | |
run: | | |
for i in {1..10}; do | |
if mongosh --eval "db.runCommand({ ping: 1 })"; then | |
echo "MongoDB is ready"; | |
exit 0; | |
fi; | |
echo "Waiting for MongoDB..."; | |
sleep 5; | |
done; | |
exit 1 | |
- name: Run build | |
run: npm run build | |
- name: Run production | |
run: npm run dev | |
- name: Run tests | |
env: | |
MONGO_URI: mongodb://localhost:27017/poet_app | |
run: npm test |