นี่คือการกระทำของ GitHub เพื่อตรวจสอบลิงก์ที่เสียในไฟล์หรือหน้าเว็บของคุณ MUFFET ใช้สำหรับงานตรวจสอบ 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 ไดเรกทอรี มีเว็บเซิร์ฟเวอร์แคดดี้เริ่มต้นระหว่างการทดสอบที่ใช้ชื่อโฮสต์จากพารามิเตอร์ 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 Checker Muffet |
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ตัวอย่างคือการใช้ Hugo
ส่วนที่บังคับคือชื่อที่เก็บ 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 เพื่อสร้างหน้าของฉัน
อีกตัวอย่างหนึ่งเมื่อตรวจสอบหน้าเว็บที่เก็บไว้ในดิสก์ของคุณ ในกรณีนี้ฉันใช้หน้าเว็บที่สร้างขึ้นใน ./tests/ ไดเรกทอรีจากที่เก็บ Git นี้:
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 สามารถพบได้ที่นี่: https://github.com/peaceiris/actions-gh-pages/
ลิงค์ต่อไปนี้มีตัวอย่างจริงของตัวตรวจสอบลิงค์ที่เสียของฉัน:
Hugo-Build
VuePress-Build-Check-Deploy
ตรวจสอบเป็นระยะ ๆ