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@v4
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@v4
33 id: node
34 with:
35 node-version: 22.x
36 check-latest: contains('22.x', '.x')
37 cache: npm
38 - name: Install Latest npm
39 uses: ./.github/actions/install-latest-npm
40 with:
41 node: ${{ steps.node.outputs.node-version }}
42 - name: Install Dependencies
43 run: npm i --no-audit --no-fund
44 - name: Rebuild deps
45 run: npm rebuild
46
47 - name: Setup Pages
48 uses: actions/configure-pages@v4
49
50 - name: Restore cache
51 id: cache-gatsby
52 uses: actions/cache/restore@v4
53 with:
54 key: ${{ runner.os }}-gatsby-${{ github.ref_name }}
55 path: |
56 public
57 .cache
58
59 - name: Build documentation
60 run: npm run build
61 env:
62 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63
64 - name: Save cache
65 uses: actions/cache/save@v4
66 with:
67 key: ${{ steps.cache-gatsby.outputs.cache-primary-key }}
68 path: |
69 public
70 .cache
71
72 - name: Upload artifact
73 uses: actions/upload-pages-artifact@v3
74 with:
75 path: './public'
76
77 deploy:
78 permissions:
79 pages: write
80 actions: read
81 id-token: write
82 environment:
83 name: github-pages
84 url: ${{ steps.deployment.outputs.page_url }}
85 runs-on: ubuntu-latest
86 needs: build-and-upload
87 steps:
88 - name: Deploy to GitHub Pages
89 id: deployment
90 uses: actions/deploy-pages@v4
91 with:
92 preview: ${{ github.event_name == 'pull_request' }}