Skip to content

Commit e82b968

Browse files
committed
Add environments
1 parent 8cc548a commit e82b968

File tree

1 file changed

+55
-32
lines changed

1 file changed

+55
-32
lines changed

.github/workflows/deploy-sdk.yml

Lines changed: 55 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
1212
permissions:
13-
contents: read
13+
contents: write
1414
pages: write
1515
id-token: write
1616

@@ -130,17 +130,17 @@ jobs:
130130
fi
131131
echo "npm_tag=$npm_tag" >> $GITHUB_OUTPUT
132132
133-
# - name: Get build-output
134-
# uses: actions/download-artifact@v5
135-
# with:
136-
# name: build-release
137-
# path: packages/sdk
133+
- name: Get build-output
134+
uses: actions/download-artifact@v5
135+
with:
136+
name: build-release
137+
path: packages/sdk
138138

139-
# - uses: actions/setup-node@v4
140-
# with:
141-
# node-version: ${{ env.NODE_VERSION }}
142-
# cache: yarn
143-
# registry-url: 'https://registry.npmjs.org'
139+
- uses: actions/setup-node@v4
140+
with:
141+
node-version: ${{ env.NODE_VERSION }}
142+
cache: yarn
143+
registry-url: 'https://registry.npmjs.org'
144144

145145
# - name: Publish to NPM
146146
# run: |
@@ -159,9 +159,8 @@ jobs:
159159
deploy-typedoc:
160160
needs:
161161
- upload-release
162-
# environment:
163-
# name: github-pages
164-
# url: ${{ steps.deployment.outputs.page_url }}
162+
environment:
163+
name: github-pages
165164
runs-on: ubuntu-22.04
166165
steps:
167166
- name: Checkout
@@ -173,28 +172,52 @@ jobs:
173172
path: typedoc
174173
name: typedoc-build
175174

176-
- name: Setup Pages
177-
uses: actions/configure-pages@v5
175+
# Clone old `gh-pages` branch so we can later build a list of
176+
# available documentation versions.
177+
- name: Clone old gh-pages content
178+
run: |
179+
# Make a local work folder
180+
mkdir -p gh-pages
181+
182+
# Copy its content into local `gh-pages` folder
183+
git clone --branch gh-pages --depth 1 https://github.com/${{ github.repository }} old-gh-pages
184+
cp -r old-gh-pages/* gh-pages/ || true
178185
179-
# Put docs into a versioned subfolder
180-
- name: Move typedoc into versioned folder
186+
# Put new docs into a versioned subfolder
187+
- name: Generate versioned subfolder
181188
run: |
182-
VERSION=${{ steps.get_tag.outputs.tag }}
183-
mkdir -p docs/$VERSION
184-
cp -r typedoc/* docs/latest
189+
VERSION=${{ needs.upload-release.outputs.tag }}
190+
mkdir -p gh-pages/$VERSION
191+
cp -r typedoc/* gh-pages/$VERSION
185192
186-
# (Optional) symlink "latest" newest tag
187-
- name: Update latest symlink
193+
# Update the "latest" subfolder content with the newest doc version.
194+
- name: Update `latest` subfolder content
188195
if: needs.upload-release.outputs.npm_tag == 'latest'
189196
run: |
190-
rm -rf docs/latest
191-
mv typedoc/* docs/$VERSION
197+
mkdir -p gh-pages/latest
198+
rm -rf gh-pages/latest/*
199+
cp -r typedoc/* gh-pages/latest
192200
193-
- name: Upload GH Pages artifact
194-
uses: actions/upload-pages-artifact@v3
195-
with:
196-
path: './docs'
201+
# Generate list of available documentation versions.
202+
# This needs to be done after the `gh-pages` branch has been fetched with the old docs.
203+
- name: Generate docs index
204+
run: |
205+
echo "<!DOCTYPE html>" > gh-pages/index.html
206+
echo "<html><head><title>Documentation Versions</title></head><body>" >> gh-pages/index.html
207+
echo "<h1>Available Documentation Versions</h1><ul>" >> gh-pages/index.html
208+
209+
# Loop over all directories in gh-pages/
210+
for d in gh-pages/*/ ; do
211+
version=$(basename "$d")
212+
echo "<li><a href=\"./$version/\">$version</a></li>" >> gh-pages/index.html
213+
done
197214
198-
- name: Deploy to GitHub Pages
199-
id: deployment
200-
uses: actions/deploy-pages@v4
215+
echo "</ul>" >> gh-pages/index.html
216+
echo "</body></html>" >> gh-pages/index.html
217+
218+
- name: Deploy
219+
uses: peaceiris/actions-gh-pages@v4
220+
with:
221+
github_token: ${{ secrets.GITHUB_TOKEN }}
222+
publish_dir: ./gh-pages
223+
keep_files: true

0 commit comments

Comments
 (0)