Build, Test, and Publish #5
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, Test, and Publish | |
on: | |
workflow_dispatch: | |
permissions: | |
pages: write | |
id-token: write | |
jobs: | |
build-test-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Install dependencies | |
run: npm ci | |
- name: Generate and build API | |
run: npm run buildApi | |
- name: Install dependencies in tests directory | |
working-directory: tests | |
run: npm ci | |
- name: Link cwmjs dependency from src to tests | |
run: npm run link | |
- name: Run tests | |
working-directory: tests | |
run: npm run test --ci | |
- name: Publish to npm | |
if: success() | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
working-directory: cwmsjs | |
run: npm publish --access public | |
- name: Build docs | |
if: success() | |
run: npm run buildDocs | |
- name: Upload docs artifact | |
if: success() | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./cwmsjs/docs | |
deploy-docs: | |
needs: build-test-publish | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |