Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do open tickets about broken links #1960

Merged
merged 4 commits into from
Mar 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions .github/actions/deploy-to-github-pages/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,16 @@ runs:
shell: bash
run: |
echo "result=$(echo "$base_url" |
sed 's|^\(.*\)\(/git-scm\.com\)$|(\1)?\2(.*)|') file://$PWD/public\$2" \
sed 's|^\(.*\)\(/git-scm\.com\)$|^(\1)?\2(.*)|') file://$PWD/public\$2" \
>>$GITHUB_OUTPUT
# When running in forks, do detect when links try to break out of the
# `/git-scm.com/` subdirectory
echo "remap-dotdot=$(echo "$base_url" |
sed -n 's|^\(https\?:\/\/.*\)\(/git-scm\.com\)$|--remap '\''(\1.*) file://../$1'\''|p')" \
sed -n 's|^\(https\?:\/\/.*\)\(/git-scm\.com\)$|--remap '\''^(\1.*) file://../$1'\''|p')" \
>>$GITHUB_OUTPUT
# When running in forks, do treat https://git-scm.com links as if they were relative
test https://git-scm.com = "$base_url" ||
echo "remap-git-scm=--remap '^https?://git-scm.com(.*) file://$PWD/public\$1'" >>$GITHUB_OUTPUT

- name: check for downgrades to unencrypted HTTP
if: startsWith(env.base_url, 'https://')
Expand All @@ -163,6 +166,7 @@ runs:
--base '${{ env.base_url }}'
--remap '${{ steps.remap.outputs.result }}'
${{ steps.remap.outputs.remap-dotdot }}
${{ steps.remap.outputs.remap-git-scm }}
--exclude file:///path/to/repo.git/
--exclude file:///caminho/para/o/reposit%C3%B3rio.git/
--exclude file:///ruta/a/repositorio.git/
Expand All @@ -176,8 +180,7 @@ runs:
fail: false
failIfEmpty: false # needed because its default overrides `fail = false`

- name: ${{ env.lychee_exit_code != '0' && 'open or update' || 'maybe close' }} link checker issue
if: env.lychee_exit_code != ''
- name: ${{ steps.lychee.outputs.exit_code != '0' && 'open or update' || 'maybe close' }} link checker issue
uses: actions/github-script@v7
with:
github-token: ${{ inputs.github-token }}
Expand Down Expand Up @@ -211,13 +214,13 @@ runs:
})()

if (issues.data.items.length === 0) {
if (process.env.lychee_exit_code !== '0') {
if ('${{ steps.lychee.outputs.exit_code }}' !== '0') {
await github.rest.issues.create({ ...req, title: 'Link Checker Report', body, labels: ['linkchecker'] })
}
} else {
req.issue_number = issues.data.items[0].number
await github.rest.issues.createComment({ ...req, body })
if (process.env.lychee_exit_code === '0') {
if ('${{ steps.lychee.outputs.exit_code }}' === '0') {
await github.rest.issues.update({ ...req, state: 'closed' })
}
}
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ jobs:
curl -Lo /tmp/hugo.deb https://github.com/gohugoio/hugo/releases/download/v$HUGO_VERSION/hugo_extended_${HUGO_VERSION}_linux-amd64.deb &&
sudo dpkg -i /tmp/hugo.deb

- name: work around a broken link
# See https://github.com/jnavila/git-manpages-l10n/pull/131;
# A space is missing in "https://git-scm.com/docs上查看"
run: |
sed -i 's,\(href="\(https://git-scm.com/docs\)\)\(上查看\)"\([^>]*>\)\2\3\(</a>\),\1"\4\1\5 \3,p' \
external/docs/content/docs/git/zh_HANS-CN.html

- name: run Hugo to build the pages
run: hugo

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