1 name: Publish
2
3 on:
4 push:
5 branches:
6 {{#each branchPatterns}}
7 - {{ . }}
8 {{/each}}
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 {{> stepsSetupYml }}
26 - name: Rebuild deps
27 run: npm rebuild
28
29 - name: Setup Pages
30 uses: actions/configure-pages@v4
31
32 - name: Restore cache
33 id: cache-gatsby
34 uses: actions/cache/restore@v4
35 with:
36 key: $\{{ runner.os }}-gatsby-$\{{ github.ref_name }}
37 path: |
38 public
39 .cache
40
41 - name: Build documentation
42 run: npm run build
43 env:
44 GITHUB_TOKEN: $\{{ secrets.GITHUB_TOKEN }}
45
46 - name: Save cache
47 uses: actions/cache/save@v4
48 with:
49 key: $\{{ steps.cache-gatsby.outputs.cache-primary-key }}
50 path: |
51 public
52 .cache
53
54 - name: Upload artifact
55 uses: actions/upload-pages-artifact@v3
56 with:
57 path: './public'
58
59 deploy:
60 permissions:
61 pages: write
62 actions: read
63 id-token: write
64 environment:
65 name: github-pages
66 url: $\{{ steps.deployment.outputs.page_url }}
67 runs-on: ubuntu-latest
68 needs: build-and-upload
69 steps:
70 - name: Deploy to GitHub Pages
71 id: deployment
72 uses: actions/deploy-pages@v4
73 with:
74 preview: $\{{ github.event_name == 'pull_request' }}