CHORE overhaul project setup with esbuild #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: NodeJS demo build and deploy GitHub page and node package publishing | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
cache: 'npm' | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
path: "**/node_modules" | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install dependencies | |
run: npm ci | |
- name: build demo | |
run: npm run build | |
- name: upload docs artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: page | |
path: docs | |
if-no-files-found: error | |
- name: copy src code for publishing to the dist folder | |
run: cp -r ./src/ ./dist | |
- name: upload dist artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: dist | |
if-no-files-found: error | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: page | |
path: . | |
- uses: actions/configure-pages@v4 | |
- uses: actions/upload-pages-artifact@v3 | |
with: | |
path: . | |
- id: deployment | |
uses: actions/deploy-pages@v4 | |
# publish: | |
# needs: build | |
# runs-on: ubuntu-latest | |
# steps: | |
# - uses: actions/download-artifact@v4 | |
# with: | |
# name: dist | |
# path: . | |
# - name: Publish package | |
# uses: JS-DevTools/npm-publish@v3 | |
# with: | |
# access: public | |
# token: ${{ secrets.NPM_TOKEN }} |