Skip to content

Node.js Aplication #308

Node.js Aplication

Node.js Aplication #308

Workflow file for this run

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
name: Node.js Aplication
on:
push:
branches:
- main
schedule:
- cron: "0 0 * * 0-6"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Use Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
- run: npm ci
- run: npm run build --if-present
- run: npm install -g json-server
- name: Start json-server
run: json-server -w src/js/data.json --port 3000 &
- name: Install Playwright browsers
run: npx playwright install
- name: Execute JavaScript
run: |
node src/js/GroupScript.js
node src/js/GameScript.js
- name: Stop json-server
run: kill $(pgrep -f "json-server")
- name: Check for changes
id: check_changes
run: |
git diff --exit-code src/js/data.json || echo "::set-output name=changed::true"
- name: Commit changes
if: steps.check_changes.outputs.changed == 'true'
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git add src/js/data.json
git commit -m "Auto-commit by GitHub Actions"
git push
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}