Add new GitHub Action for test examples #1
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: Build and Deploy OpenLIME Examples | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Permette di eseguire manualmente il workflow | |
workflow_dispatch: | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build library | |
run: npm run rollup | |
- name: Setup and start web server | |
run: | | |
# Installa un server web leggero | |
npm install -g http-server | |
# Avvia il server in background dalla directory dist | |
nohup npx http-server ./dist -p 8080 & | |
# Aspetta che il server sia pronto | |
sleep 5 | |
# Verifica che il server sia attivo | |
curl http://localhost:8080 || exit 1 | |
# Optional: deploy to GitHub Pages | |
- name: Deploy to GitHub Pages | |
if: github.ref == 'refs/heads/main' | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: ./dist |