Skip to content

Commit b3fab8a

Browse files
authored
Merge pull request git#1960 from dscho/do-open-tickets-about-broken-links
Do open tickets about broken links
2 parents 4154b3f + c902ac8 commit b3fab8a

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

.github/actions/deploy-to-github-pages/action.yml

+9-6
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,16 @@ runs:
131131
shell: bash
132132
run: |
133133
echo "result=$(echo "$base_url" |
134-
sed 's|^\(.*\)\(/git-scm\.com\)$|(\1)?\2(.*)|') file://$PWD/public\$2" \
134+
sed 's|^\(.*\)\(/git-scm\.com\)$|^(\1)?\2(.*)|') file://$PWD/public\$2" \
135135
>>$GITHUB_OUTPUT
136136
# When running in forks, do detect when links try to break out of the
137137
# `/git-scm.com/` subdirectory
138138
echo "remap-dotdot=$(echo "$base_url" |
139-
sed -n 's|^\(https\?:\/\/.*\)\(/git-scm\.com\)$|--remap '\''(\1.*) file://../$1'\''|p')" \
139+
sed -n 's|^\(https\?:\/\/.*\)\(/git-scm\.com\)$|--remap '\''^(\1.*) file://../$1'\''|p')" \
140140
>>$GITHUB_OUTPUT
141+
# When running in forks, do treat https://git-scm.com links as if they were relative
142+
test https://git-scm.com = "$base_url" ||
143+
echo "remap-git-scm=--remap '^https?://git-scm.com(.*) file://$PWD/public\$1'" >>$GITHUB_OUTPUT
141144
142145
- name: check for downgrades to unencrypted HTTP
143146
if: startsWith(env.base_url, 'https://')
@@ -163,6 +166,7 @@ runs:
163166
--base '${{ env.base_url }}'
164167
--remap '${{ steps.remap.outputs.result }}'
165168
${{ steps.remap.outputs.remap-dotdot }}
169+
${{ steps.remap.outputs.remap-git-scm }}
166170
--exclude file:///path/to/repo.git/
167171
--exclude file:///caminho/para/o/reposit%C3%B3rio.git/
168172
--exclude file:///ruta/a/repositorio.git/
@@ -176,8 +180,7 @@ runs:
176180
fail: false
177181
failIfEmpty: false # needed because its default overrides `fail = false`
178182

179-
- name: ${{ env.lychee_exit_code != '0' && 'open or update' || 'maybe close' }} link checker issue
180-
if: env.lychee_exit_code != ''
183+
- name: ${{ steps.lychee.outputs.exit_code != '0' && 'open or update' || 'maybe close' }} link checker issue
181184
uses: actions/github-script@v7
182185
with:
183186
github-token: ${{ inputs.github-token }}
@@ -211,13 +214,13 @@ runs:
211214
})()
212215
213216
if (issues.data.items.length === 0) {
214-
if (process.env.lychee_exit_code !== '0') {
217+
if ('${{ steps.lychee.outputs.exit_code }}' !== '0') {
215218
await github.rest.issues.create({ ...req, title: 'Link Checker Report', body, labels: ['linkchecker'] })
216219
}
217220
} else {
218221
req.issue_number = issues.data.items[0].number
219222
await github.rest.issues.createComment({ ...req, body })
220-
if (process.env.lychee_exit_code === '0') {
223+
if ('${{ steps.lychee.outputs.exit_code }}' === '0') {
221224
await github.rest.issues.update({ ...req, state: 'closed' })
222225
}
223226
}

.github/workflows/ci.yml

+8
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ jobs:
1919
curl -Lo /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v$HUGO_VERSION/hugo_extended_${HUGO_VERSION}_linux-amd64.deb &&
2020
sudo dpkg -i /tmp/hugo.deb
2121
22+
- name: work around a broken link
23+
# See https://github.com/jnavila/git-manpages-l10n/pull/131;
24+
# A space is missing in "https://git-scm.com/docs上查看"
25+
run: |
26+
sed -i 's,\(href="\(https://git-scm.com/docs\)\)\(上查看\)"\([^>]*>\)\2\3\(</a>\),\1"\4\1\5 \3,p' \
27+
external/docs/content/docs/git/zh_HANS-CN.html
28+
2229
- name: run Hugo to build the pages
2330
run: hugo
2431

@@ -64,6 +71,7 @@ jobs:
6471
with:
6572
args: >-
6673
--offline
74+
--remap '^https?://git-scm.com(.*) file://'"$PWD"'/public$1'
6775
--fallback-extensions html
6876
--exclude file:///path/to/repo.git/
6977
--exclude file:///caminho/para/o/reposit%C3%B3rio.git/

0 commit comments

Comments
 (0)