-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (75 loc) · 2.45 KB
/
doc-publish-typescript-project.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
82
83
84
85
86
87
88
name: Build and Document Application
on:
workflow_call:
secrets:
token:
description: 'The GitHub/npm token'
required: true
jobs:
build-docs:
name: Build Docs
runs-on: ubuntu-latest
env:
working-directory: ./
defaults:
run:
working-directory: ${{env.working-directory}}
steps:
- name: Setup
uses: OpenPhone/gha/.github/actions/setup@v5
with:
token: ${{ secrets.token }}
working-directory: ${{env.working-directory}}
- name: Typecheck
run: npm run typecheck
- name: Lint
run: npm run lint
- name: Build
run: npm run build
- name: Generate Docs
run: npm run doc
- name: Setup Pages
uses: actions/configure-pages@v3
with:
token: ${{ secrets.token }}
- name: Update Swagger UI
env:
SWAGGER_YAML: "openapi.json"
run: |
mkdir -p docs
cd docs
release_tag=$(curl -sL https://api.github.com/repos/swagger-api/swagger-ui/releases/latest | jq -r ".tag_name")
echo "release_tag=$release_tag" >> $GITHUB_OUTPUT
# Download the release
curl -sL -o $release_tag https://api.github.com/repos/swagger-api/swagger-ui/tarball/$release_tag
# Extract the dist directory
tar -xzf $release_tag --strip-components=1 $(tar -tzf $release_tag | head -1 | cut -f1 -d"/")/dist
rm $release_tag
# Move index.html to the root
mv dist/index.html .
# Fix references in dist/swagger-initializer and index.html
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$SWAGGER_YAML|g" dist/swagger-initializer.js
sed -i "s|href=\"./|href=\"dist/|g" index.html
sed -i "s|src=\"./|src=\"dist/|g" index.html
sed -i "s|href=\"index|href=\"dist/index|g" index.html
- name: Upload Artifact
uses: actions/upload-pages-artifact@v1
with:
path: "./docs"
deploy-docs:
name: Deploy Docs to Github Pages
runs-on: ubuntu-latest
needs: build-docs
permissions:
pages: write
id-token: write
environment:
# environment created automatically by GitHub
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
with:
token: ${{ secrets.token }}