-
Notifications
You must be signed in to change notification settings - Fork 1
81 lines (67 loc) · 2.25 KB
/
docs-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# This workflow will publish API docs to GitHub Pages when a new release tag is added to the main branch
name: Publish API docs to GitHub Pages
on:
release:
types:
- published
workflow_dispatch:
jobs:
check-tag:
runs-on: ubuntu-latest
steps:
- name: Fetch the latest release tag
id: fetch_latest_release_tag
run: |
LATEST_TAG=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r '.tag_name')
echo "LATEST_TAG=$LATEST_TAG" >> "$GITHUB_OUTPUT"
echo "The latest release tag is $LATEST_TAG"
- name: Check release tag on release event
if: ${{ github.event_name == 'release' }}
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
LATEST_TAG: ${{ steps.fetch_latest_release_tag.outputs.LATEST_TAG }}
run: |
if [[ "$RELEASE_TAG" != "$LATEST_TAG" ]]; then
echo "Release tag $RELEASE_TAG does not match the latest tag $LATEST_TAG."
exit 1
else
echo "Release tag $RELEASE_TAG matches the latest tag $LATEST_TAG."
fi
build:
needs: check-tag
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v4
with:
ref: ${{ steps.fetch_latest_release_tag.outputs.LATEST_TAG }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install
run: npm ci
- name: Build docs
run: npm run docs
- name: Upload static files as artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/
deploy:
needs: build
concurrency:
group: docs-publish
cancel-in-progress: true
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
# Deploy to the github-pages environment
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4