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