Il s'agit d'une action GitHub pour vérifier le lien brisé dans vos fichiers statiques ou pages Web. Le coutume est utilisé pour la tâche de vérification de l'URL.
Voir l'exemple d'action GitHub de base pour effectuer des contrôles périodiques (hebdomadaire) contre 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 pageDécouvrez la vraie démo:
Cette action de déploiement peut être combinée avec des générateurs de sites statiques (Hugo, Mkdocs, Gatsby, Gitbook, MDBook, etc.). Les exemples suivants prévoient que la page Web soit stockée dans le répertoire ./build . Un serveur Web Caddy est démarré pendant les tests qui utilise le nom d'hôte à partir du paramètre URL et le service des pages Web (voir les détails de 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 parametersVoulez-vous sauter l'étape de construction docker? OK, le mode script est également disponible:
- 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 Variables d'environnement utilisées par le script ./entrypoint.sh .
| Variable | Défaut | Description |
|---|---|---|
INPUT_CMD_PARAMS | --buffer-size=8192 --max-connections=10 --color=always --verbose | Paramètres de ligne de commande pour Url Checker Muffet |
INPUT_DEBUG | FAUX | Activer le mode de débogage pour le script ./entrypoint.sh ( set -x ) |
INPUT_PAGES_PATH | Chemin relatif vers le répertoire avec des pages Web locales | |
INPUT_URL | ( Obligatoire / requis ) | URL qui sera vérifiée |
Pipeline pour les vérifications des liens périodiques:
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 ' Exemple d'action 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 Essayons d'automatiser autant que possible la création des pages Web.
La situation idéale nécessite la convention de dénomination du référentiel, où le nom du référentiel GitHub doit correspondre à l'URL où il sera hébergé.
La partie obligatoire est le nom du référentiel awsug.cz qui est le même que le domaine:
Les pages Web seront stockées sous forme de pages GitHub sur son propre domaine.
Le fichier d'action GH peut ressembler:
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 : trueL'exemple est d'utiliser Hugo.
La partie obligatoire est le nom du référentiel k8s-harbor qui est la partie du répertoire au et de ruzickap.github.io :
Dans l'exemple, les pages Web utiliseront le domaine 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 : trueDans ce cas, j'utilise VuePress pour créer ma page.
Un autre exemple lors de la vérification de la page Web stockée localement sur votre disque. Dans ce cas, j'utilise la page Web créée dans le répertoire ./tests/ à partir de ce référentiel 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.shSortir:
*** 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...
Quelques autres exemples de création et de vérification des pages Web à l'aide de générateurs de sites statiques et d'actions GitHub peuvent être trouvés ici: https://github.com/peaceiris/actions-gh-pages/
Les liens suivants contient de vrais exemples de mon vérificateur de lien cassé:
hugo-build
Vuepress-build-check-deploi
cochées de liaison périodique