action my broken link checker
v2.7.0
这是一个github操作,可以检查静态文件或网页中的损坏链接。松饼用于URL检查任务。
请参阅基本的GitHub动作示例(每周)针对Mkdocs.org进行定期检查:
on :
schedule :
- cron : ' 0 0 * * 0 '
name : Check markdown links
jobs :
my-broken-link-checker :
name : Check broken links
runs-on : ubuntu-latest
steps :
- name : Check
uses : ruzickap/action-my-broken-link-checker@v2
with :
url : https://www.mkdocs.org
cmd_params : " --one-page-only --max-connections=3 --color=always " # Check just one page查看真正的演示:
该部署动作可以与静态站点生成器(Hugo,Mkdocs,Gatsby,Gitbook,MDBook等)结合使用。以下示例希望将网页存储在./build build目录中。在测试期间启动了一个Caddy Web服务器,该服务器使用URL参数中的主机名并提供网页(请参阅Entrypoint.sh中的详细信息)。
- name : Check
uses : ruzickap/action-my-broken-link-checker@v2
with :
url : https://www.example.com/test123
pages_path : ./build/
cmd_params : ' --buffer-size=8192 --max-connections=10 --color=always --skip-tls-verification --header="User-Agent:curl/7.54.0" --timeout=20 ' # muffet parameters您想跳过Docker构建步骤吗?好的,脚本模式也可用:
- name : Check
env :
INPUT_URL : https://www.example.com/test123
INPUT_PAGES_PATH : ./build/
INPUT_CMD_PARAMS : ' --buffer-size=8192 --max-connections=10 --color=always --header="User-Agent:curl/7.54.0" --skip-tls-verification ' # --skip-tls-verification is mandatory parameter when using https and "PAGES_PATH"
run : wget -qO- https://raw.githubusercontent.com/ruzickap/action-my-broken-link-checker/v2/entrypoint.sh | bash 环境变量./entrypoint.sh脚本。
| 多变的 | 默认 | 描述 |
|---|---|---|
INPUT_CMD_PARAMS | --buffer-size=8192 --max-connections=10 --color=always --verbose | URL检查器消声器的命令行参数 |
INPUT_DEBUG | 错误的 | 启用./entrypoint.sh脚本( set -x )的调试模式 |
INPUT_PAGES_PATH | 使用本地网页到目录的相对路径 | |
INPUT_URL | (强制 /必需) | 将检查的URL |
周期性链接检查的管道:
name : periodic-broken-link-checks
on :
workflow_dispatch :
push :
paths :
- .github/workflows/periodic-broken-link-checks.yml
schedule :
- cron : ' 3 3 * * 3 '
jobs :
broken-link-checker :
runs-on : ubuntu-latest
steps :
- name : Setup Pages
id : pages
uses : actions/configure-pages@v3
- name : Check broken links
uses : ruzickap/action-my-broken-link-checker@v2
with :
url : ${{ steps.pages.outputs.base_url }}
cmd_params : ' --buffer-size=8192 --max-connections=10 --color=always --header="User-Agent:curl/7.54.0" --timeout=20 ' github动作示例:
name : Checks
on :
push :
branches :
- main
jobs :
build-deploy :
runs-on : ubuntu-latest
steps :
- name : Create web page
run : |
mkdir -v public
cat > public/index.html << EOF
<!DOCTYPE html>
<html>
<head>
My page which will be stored on my-testing-domain.com domain
</head>
<body>
Links:
<ul>
<li><a href="https://my-testing-domain.com">https://my-testing-domain.com</a></li>
<li><a href="https://my-testing-domain.com:443">https://my-testing-domain.com:443</a></li>
</ul>
</body>
</html>
EOF
- name : Check links using script
env :
INPUT_URL : https://my-testing-domain.com
INPUT_PAGES_PATH : ./public/
INPUT_CMD_PARAMS : ' --skip-tls-verification --verbose --color=always '
INPUT_DEBUG : true
run : wget -qO- https://raw.githubusercontent.com/ruzickap/action-my-broken-link-checker/v2/entrypoint.sh | bash
- name : Check links using container
uses : ruzickap/action-my-broken-link-checker@v2
with :
url : https://my-testing-domain.com
pages_path : ./public/
cmd_params : ' --skip-tls-verification --verbose --color=always '
debug : true 让我们尝试尽可能地自动化创建网页。
理想的情况需要存储库命名约定,在该约定中,GitHub存储库的名称应与托管的URL匹配。
强制性部分是存储库名awsug.cz ,与域相同:
网页将作为github页面存储在其自身域上。
GH操作文件可能看起来像:
name : hugo-build
on :
pull_request :
types : [opened, synchronize]
push :
jobs :
hugo-build :
runs-on : ubuntu-latest
steps :
- uses : actions/checkout@v2
- name : Checkout submodules
shell : bash
run : |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
- name : Setup Hugo
uses : peaceiris/actions-hugo@v2
with :
hugo-version : ' 0.62.0 '
- name : Build
run : |
hugo --gc
cp LICENSE README.md public/
echo "${{ github.event.repository.name }}" > public/CNAME
- name : Check broken links
env :
INPUT_URL : https://${{ github.event.repository.name }}
INPUT_PAGES_PATH : public
INPUT_CMD_PARAMS : ' --verbose --buffer-size=8192 --max-connections=10 --color=always --skip-tls-verification --exclude="(mylabs.dev|linkedin.com)" '
run : |
wget -qO- https://raw.githubusercontent.com/ruzickap/action-my-broken-link-checker/v2/entrypoint.sh | bash
- name : Check links using container
uses : ruzickap/action-my-broken-link-checker@v2
with :
url : https://my-testing-domain.com
pages_path : ./public/
cmd_params : ' --verbose --buffer-size=8192 --max-connections=10 --color=always --skip-tls-verification --header="User-Agent:curl/7.54.0" --exclude="(mylabs.dev|linkedin.com)" '
debug : true
- name : Deploy
uses : peaceiris/actions-gh-pages@v3
if : ${{ github.event_name }} == 'push' && github.ref == 'refs/heads/main'
env :
ACTIONS_DEPLOY_KEY : ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH : gh-pages
PUBLISH_DIR : public
with :
forceOrphan : true示例是使用雨果。
强制性部分是存储库k8s-harbor ,它是ruzickap.github.io的目录部分:
在示例中,网页将使用github的域github.io。
name : vuepress-build-check-deploy
on :
pull_request :
types : [opened, synchronize]
paths :
- .github/workflows/vuepress-build-check-deploy.yml
- docs/**
- package.json
- package-lock.json
push :
paths :
- .github/workflows/vuepress-build-check-deploy.yml
- docs/**
- package.json
- package-lock.json
jobs :
vuepress-build-check-deploy :
runs-on : ubuntu-latest
steps :
- uses : actions/checkout@v2
- name : Install Node.js 12
uses : actions/setup-node@v1
with :
node-version : 12.x
- name : Install VuePress and build the document
run : |
npm install
npm run build
cp LICENSE docs/.vuepress/dist
sed -e "s@(part-@(https://github.com/${GITHUB_REPOSITORY}/tree/main/docs/part-@" -e 's@./.vuepress/public/@./@' docs/README.md > docs/.vuepress/dist/README.md
ln -s docs/.vuepress/dist ${{ github.event.repository.name }}
- name : Check broken links
uses : ruzickap/action-my-broken-link-checker@v2
with :
url : https://${{ github.repository_owner }}.github.io/${{ github.event.repository.name }}
pages_path : .
cmd_params : ' --exclude=mylabs.dev --max-connections-per-host=5 --rate-limit=5 --timeout=20 --header="User-Agent:curl/7.54.0" --skip-tls-verification '
- name : Deploy
uses : peaceiris/actions-gh-pages@v3
if : ${{ github.event_name }} == 'push' && github.ref == 'refs/heads/main'
env :
ACTIONS_DEPLOY_KEY : ${{ secrets.ACTIONS_DEPLOY_KEY }}
PUBLISH_BRANCH : gh-pages
PUBLISH_DIR : ./docs/.vuepress/dist
with :
forceOrphan : true在这种情况下,我正在使用Vuepress来创建我的页面。
检查本地存储在磁盘上的网页时的另一个示例。在这种情况下,我正在使用此git存储库中的./tests/目录中创建的网页:
export INPUT_URL= " https://my-testing-domain.com "
export INPUT_PAGES_PATH= " ${PWD} /tests/ "
export INPUT_CMD_PARAMS= " --skip-tls-verification --verbose --color=always "
./entrypoint.sh输出:
*** INFO: Using path "/home/pruzicka/git/action-my-broken-link-checker/tests/" as domain "my-testing-domain.com" with URI "https://my-testing-domain.com"
*** INFO: [2019-12-30 14:54:22] Start checking: "https://my-testing-domain.com"
https://my-testing-domain.com/
200 https://my-testing-domain.com
200 https://my-testing-domain.com/run_tests.sh
200 https://my-testing-domain.com:443
200 https://my-testing-domain.com:443/run_tests.sh
https://my-testing-domain.com:443/
200 https://my-testing-domain.com
200 https://my-testing-domain.com/run_tests.sh
200 https://my-testing-domain.com:443
200 https://my-testing-domain.com:443/run_tests.sh
*** INFO: [2019-12-30 14:54:22] Checks completed...
可以在此处找到使用静态站点生成器和GITHUB操作构建和检查网页的其他示例:
以下链接包含我断开的链接检查器的真实示例:
雨果建造
Vuepress-Build-Check-Deploy
周期性的链接检查