-
Notifications
You must be signed in to change notification settings - Fork 426
186 lines (181 loc) · 7.58 KB
/
gh-pages.yml
File metadata and controls
186 lines (181 loc) · 7.58 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
name: gh-pages
env:
CLDR_DIR: ${{ github.workspace }}
AUTO_BRANCH: auto/tr35/main
AUTO_REMOTE: origin
# Note: we have a foot in two camps here, maybe more
#
# - docs/ldml is the spec, and it gets special handling and generation. Ends up cldr-smoke for now
# - docs/rfc needs to end up somewhere. for now, generate to github.io
# - docs/site is an entire 'site' that gets deployed to what will be cldr.unicode.org
# This is now handled in site.yml
permissions:
pages: write
deployments: write
id-token: write
actions: read
on:
pull_request:
push:
branches:
- main
- "maint/maint-*"
tags:
- "release-*"
# Only run if docs change.
paths:
- "tools/scripts/tr-archive/**"
- "docs/**"
- ".github/workflows/gh-pages.yml"
jobs:
build:
name: "Build Github Pages"
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v4
with:
lfs: false
fetch-depth: 1
- name: Cache local npm repository
uses: actions/cache@v4
with:
path: ~/.npm
key: ${{ runner.os }}-nodetr-${{ hashFiles('tools/scripts/tr-archive/package-lock.json') }}
restore-keys: |
${{ runner.os }}-nodetr-
nodetr-
- uses: nodenv/actions/node-version@v4 # setup using .node-version
- name: Run TR archiver
# Note: will update ToC if out of date
run: "cd tools/scripts/tr-archive/ && npm ci && npm run build"
- name: Run Kbd Charts
run: "cd docs/charts/keyboards && npm ci && npm run build"
- name: Upload tr35.zip
uses: actions/upload-artifact@v4
with:
name: tr35-spec
path: tools/scripts/tr-archive/tr35.zip
- name: "Check internal anchors in spec"
# Note: see CLDR-16526 for making this an error
# see <tools/scripts/tr-archive/README.md> for instructions
run: "cd tools/scripts/tr-archive/ && npm run extract-link-targets"
- name: Lint Markdown
# Warn, don't fail yet
run: npx markdownlint-cli *.md {specs,docs}/*.md || (echo Warning, please fix these ; true)
- name: Note any changes
# if the archiver had to update anything, or if anchors changed
run: git status ; git diff
- name: Restore lychee cache
uses: actions/cache@v3
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- name: Run lychee
uses: lycheeverse/lychee-action@v1
with:
args: "-n --cache --max-cache-age 10d docs/rfc docs/ldml"
fail: false
format: markdown
output: linkcheck.md
- name: Link Checker Summary
run: cat linkcheck.md >> $GITHUB_STEP_SUMMARY
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3.2
bundler-cache: true
- name: Build Jekyll part of the site (not spec, not site/)
run: |
gem install bundler github-pages kramdown-parser-gfm # should pull in jekyll, etc.
cd docs && github-pages build && mkdir -vp ../_site/ldml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Rearrange stuff
run: "cp -vr tools/scripts/tr-archive/dist/* ./_site/ldml/ && cp tools/scripts/tr-archive/reports-v2.css ./_site/"
- name: Deploy to GitHub Pages (main)
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v3
- name: Deploy to Smoketest
if: github.repository == 'unicode-org/cldr' && github.event_name == 'push'
shell: bash
env:
RSA_KEY_CCC: ${{ secrets.RSA_KEY_CCC }}
# the SSH port
CCC_USER: ${{ secrets.CCC_USER }}
CCC_PORT: 22
# the SSH host
CCC_HOST: cldr-smoke.unicode.org
# the ~/.ssh/known_hosts line mentioning SMOKETEST_HOST
CCC_KNOWNHOSTS: ${{ secrets.CCC_KNOWNHOSTS }}
run: |
echo "::group::Publish HTML"
echo "${RSA_KEY_CCC}" > ${HOME}/.key && chmod go= ${HOME}/.key
echo "${CCC_KNOWNHOSTS}" > ${HOME}/.knownhosts && chmod go= ${HOME}/.knownhosts
rsync -cav --delete-after -e "ssh -o UserKnownHostsFile=${HOME}/.knownhosts -i ${HOME}/.key -p ${CCC_PORT}" ./_site/ ${CCC_USER}@${CCC_HOST}:spec/$(basename ${GITHUB_REF_NAME})/
echo "::endgroup::"
echo "Now go to https://cldr-smoke.unicode.org/spec/"$(basename ${GITHUB_REF_NAME})
- name: Verify SpecFix Changes
if: github.repository == 'unicode-org/cldr' && github.event_name == 'push' && github.ref == 'refs/heads/main'
id: gitstatus
run: |
echo '### tr35 fixups' >> $GITHUB_STEP_SUMMARY
echo >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
git status | tee -a $GITHUB_STEP_SUMMARY
git diff --stat | tee -a $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
( echo changecount=$(git diff 2>/dev/null | wc -l) ) | tee -a $GITHUB_OUTPUT
# bump modification section if needed.
bash tools/scripts/tr-archive/check-mod-section.sh HEAD "origin/$BASE_REF" >/dev/null || echo '<!--' 'Auto SpecFix' $(date) '-->' | tee -a docs/ldml/tr35-modifications.md
env:
BASE_REF: ${{ github.base_ref }}
- name: Update SpecFix branch
if: github.repository == 'unicode-org/cldr' && github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.gitstatus.outputs.changecount > 0
run: |
set -euxo pipefail
git config user.name 'gh-pages.yml [bot]'
git config user.email 'unicode-org@users.noreply.github.com'
git add docs/ldml
bash .github/workflows/cldr-modify-commit.sh gh-pages.yml SpecFix
git log -n 1
git checkout -b ${AUTO_BRANCH}
# reset origin using token
git remote set-url ${AUTO_REMOTE} "https://unicode-org:${GH_TOKEN}@github.com/unicode-org/cldr.git"
# push ONLY if files under common/ are out of date.
bash .github/workflows/cldr-modify-push-if-needed.sh ${AUTO_REMOTE} ${AUTO_BRANCH} docs/ldml/
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Open SpecFix PR
if: github.repository == 'unicode-org/cldr' && github.event_name == 'push' && github.ref == 'refs/heads/main' && steps.gitstatus.outputs.changecount > 0
run: |
set -euxo pipefail
( gh pr create \
--title $(git log --pretty=%s HEAD | head -1 | cut -d' ' -f1)" auto: SpecFix" \
--body $(git log --pretty=%s HEAD | head -1 | cut -d' ' -f1)" Automatically created, see CLDR-16083" \
--base 'main' \
--reviewer 'unicode-org/cldr-brs' \
--label 'automatic' \
--head ${AUTO_BRANCH} \
| tee -a $GITHUB_STEP_SUMMARY ) || ( echo "# Could not create PR - may already exist" | tee -a $GITHUB_STEP_SUMMARY )
env:
GH_TOKEN: ${{ github.token }}
deploy:
name: "Deploy to GitHub Pages"
# only deploy from main branch of main repo
if: github.repository == 'unicode-org/cldr' && github.event_name == 'push' && github.ref == 'refs/heads/main'
environment:
name: github-pages
url: ${{steps.deployment.outputs.page_url}}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4.0.5
# only run one deployment at once.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true