Repository navigation
113 lines (103 loc) · 4.31 KB
/
Copy pathdeploy-demo.yml
File metadata and controls
113 lines (103 loc) · 4.31 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Builds the interactive browser demo (shared webview bundle + mock data) and
# publishes it to GitHub Pages.
#
# It runs after the "Build & Publish Extensions" workflow finishes — which is the
# last link of the release chain (push → Translate i18n → Build & Publish
# Extensions → Deploy demo), so the demo is always redeployed from the exact code
# that was just released, and never races ahead of the extensions. Use the manual
# "Run workflow" button for an out-of-band redeploy.
#
# The demo build is plain Node + esbuild — no Windows/VS SDK — so it is happy on
# either a self-hosted Linux runner or a GitHub-hosted one. Which one it uses is
# resolved by the `runners` job below; see the comment there.
#
# One-time setup: repo Settings → Pages → Build and deployment → Source =
# "GitHub Actions". Then the demo is live at:
# https://hunkontech.github.io/git_Revision_Graph/
name: Deploy demo to GitHub Pages
on:
# Strictly the last link of the release chain:
# push → Translate i18n → Build & Publish Extensions → Deploy demo
# No direct `push` trigger — the demo redeploys only after a release build
# finishes, so it never races ahead of the extensions.
workflow_run:
workflows: ["Build & Publish Extensions"]
types: [completed]
# Manual re-deploy (e.g. after changing this workflow) without a release.
workflow_dispatch:
# Allow the workflow to publish to Pages.
permissions:
contents: read
pages: write
id-token: write
# One concurrent deploy; newer runs cancel an in-flight one so the live demo
# always ends up on the most recent release.
concurrency:
group: pages
cancel-in-progress: true
jobs:
# Which runner the Linux jobs use. A job whose self-hosted labels match no
# online runner sits in "queued" until GitHub cancels it a day later, and a
# workflow cannot ask whether an org runner is up (that endpoint needs
# org-admin credentials the GITHUB_TOKEN does not have) — so availability is
# declared, not detected. Set the RUNNER_LINUX repository variable to a label
# set (e.g. ["self-hosted","Linux","ARM64"]) while that fleet is up; leave it
# empty and the build runs on GitHub's runners. Same variable as the release
# workflow, so one switch moves both.
runners:
runs-on: ubuntu-latest
outputs:
linux: ${{ steps.pick.outputs.linux }}
steps:
- id: pick
env:
RUNNER_LINUX: ${{ vars.RUNNER_LINUX }}
run: |
set -euo pipefail
linux="${RUNNER_LINUX:-}"
[ -n "$linux" ] || linux='["ubuntu-latest"]'
echo "linux=$linux" >> "$GITHUB_OUTPUT"
echo "Linux jobs -> $linux"
build:
needs: runners
# Deploy only for a successful release (skip when it failed or was
# cancelled), or when triggered by hand.
if: >-
github.event_name == 'workflow_dispatch' ||
github.event.workflow_run.conclusion == 'success'
runs-on: ${{ fromJSON(needs.runners.outputs.linux) }}
steps:
- uses: actions/checkout@v4
# No `cache: npm`: on a memory-constrained self-hosted runner the
# actions/cache restore can fail to allocate its download buffer and hang
# before falling through, so npm's own cache is left to do the job.
- uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: npm ci
- name: Build demo
# The real current-release version lives in the EXTENSION_VERSION repo
# variable (bumped by the release workflow that just finished); the
# committed package.json only carries a placeholder. Inject it so the
# footer matches the latest release. Falls back to package.json when the
# variable is unset (e.g. a fresh fork).
env:
APP_VERSION: ${{ vars.EXTENSION_VERSION }}
run: npm run build:demo
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: dist/demo
deploy:
needs: [runners, build]
# deploy-pages just calls the Pages REST API — same runner as the build.
runs-on: ${{ fromJSON(needs.runners.outputs.linux) }}
timeout-minutes: 10
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4