Repository navigation
116 lines (101 loc) · 3.95 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
116 lines (101 loc) · 3.95 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
114
115
116
name: Deploy to GitHub Pages
# Publishes the site with a CI run's coverage report: the calling run's (CI calls this after every job has
# passed on a push to main), or for a manual deployment the latest successful CI run of a push to main. Never
# another run's artifacts: a pull request's CI run, a fork's included, uploads an artifact with the same name.
on:
workflow_call:
workflow_dispatch:
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
actions: read # to download the CI run's coverage artifact
pages: read # configure-pages reads the site's settings
steps:
- name: Find the CI run to publish
id: ci_run
env:
GH_TOKEN: ${{ github.token }}
EVENT_NAME: ${{ github.event_name }}
RUN_ID: ${{ github.run_id }}
SHA: ${{ github.sha }}
run: |
if [[ "$EVENT_NAME" != "workflow_dispatch" ]]; then
echo "run_id=$RUN_ID" >> "$GITHUB_OUTPUT"
echo "sha=$SHA" >> "$GITHUB_OUTPUT"
exit 0
fi
# Pull requests (forks included) run CI as pull_request events, never as pushes to this repository
run=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow test.yml --branch main --event push \
--status success --limit 1 --json databaseId,headSha --jq '.[0] | "\(.databaseId) \(.headSha)"')
if [[ -z "$run" ]]; then
echo "::error::No successful CI run of a push to main to publish"
exit 1
fi
echo "run_id=${run% *}" >> "$GITHUB_OUTPUT"
echo "sha=${run#* }" >> "$GITHUB_OUTPUT"
- name: Checkout the commit that CI run tested
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ steps.ci_run.outputs.sha }}
persist-credentials: false
- name: Setup Ruby
uses: ruby/setup-ruby@651ff0d62c5c79bed6d53ec518387aae20e72c1a # v1.329.0
with:
ruby-version: '.ruby-version'
bundler-cache: true
- name: Setup pnpm
uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0
with:
version: 10.18.3
- name: Setup Node with the pnpm cache
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: '22'
cache: 'pnpm'
cache-dependency-path: 'docs/pnpm-lock.yaml'
- name: Install docs dependencies
run: |
cd docs && pnpm install --frozen-lockfile
- name: Setup Pages
uses: actions/configure-pages@45bfe0192ca1faeb007ade9deae92b16b8254a0d # v6.0.0
with:
static_docs_generator: next
- name: Download that run's coverage report
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: coverage-ruby-rails-latest
path: docs/public/coverage/
run-id: ${{ steps.ci_run.outputs.run_id }}
github-token: ${{ github.token }}
- name: Generate YARD documentation
run: |
bundle exec yard doc --output-dir=docs/public/yard
- name: Export TypeScript types
run: |
scripts/generate_structs.rb
- name: Build with Next.js
run: cd docs && pnpm run build
- name: Upload artifact
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
with:
path: ./docs/out
deploy:
concurrency:
group: 'pages'
cancel-in-progress: false
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
permissions:
pages: write
id-token: write # deploy-pages proves the deployment came from this workflow
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@368f82528645a54fb793d4d04e342629a3f51346 # v5.0.1