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
週期性的鏈接檢查