1 # This file is automatically added by @npmcli/template-oss. Do not edit.
2
3 name: Publish
4
5 on:
6 push:
7 branches:
8 - main
9 pull_request:
10 workflow_dispatch:
11 workflow_call:
12
13 jobs:
14 build-and-upload:
15 permissions:
16 contents: read
17 pages: read
18 name: Build and Upload
19 if: github.repository_owner == 'npm'
20 runs-on: ubuntu-latest
21 defaults:
22 run:
23 shell: bash
24 steps:
25 - name: Checkout
26 uses: actions/checkout@v6
27 - name: Setup Git User
28 run: |
29 git config --global user.email "npm-cli+bot@github.com"
30 git config --global user.name "npm CLI robot"
31 - name: Setup Node
32 uses: actions/setup-node@v6
33 id: node
34 with:
35 node-version: 22.x
36 check-latest: contains('22.x', '.x')
37 cache: npm
38 - name: Install Dependencies
39 run: npm i --no-audit --no-fund
40 - name: Rebuild deps
41 run: npm rebuild
42
43 - name: Setup Pages
44 uses: actions/configure-pages@v4
45
46 - name: Restore cache
47 id: cache-gatsby
48 uses: actions/cache/restore@v4
49 with:
50 key: ${{ runner.os }}-gatsby-${{ github.ref_name }}
51 path: |
52 public
53 .cache
54
55 - name: Build documentation
56 run: npm run build
57 env:
58 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59
60 - name: Save cache
61 uses: actions/cache/save@v4
62 with:
63 key: ${{ steps.cache-gatsby.outputs.cache-primary-key }}
64 path: |
65 public
66 .cache
67
68 - name: Upload artifact
69 uses: actions/upload-pages-artifact@v3
70 with:
71 path: './public'
72
73 deploy:
74 permissions:
75 pages: write
76 actions: read
77 id-token: write
78 environment:
79 name: github-pages
80 url: ${{ steps.deployment.outputs.page_url }}
81 runs-on: ubuntu-latest
82 needs: build-and-upload
83 steps:
84 - name: Deploy to GitHub Pages
85 id: deployment
86 uses: actions/deploy-pages@v4
87 with:
88 preview: ${{ github.event_name == 'pull_request' }}