Link check: URL-decode hrefs before resolving; deploy only when site content changed
Hexo-Butterfly/pipeline/head This commit looks good
Hexo-Butterfly/pipeline/head This commit looks good
This commit is contained in:
1 parent
504a70af16
commit
796cf19c1d
1 file changed
+20
-5
Vendored
+20
-5
@@ -123,6 +123,7 @@ EOS
|
||||
cat > /tmp/smoke.py <<'EOS'
|
||||
import http.server, socketserver, os, threading, urllib.request
|
||||
import html.parser
|
||||
import urllib.parse
|
||||
|
||||
os.chdir("public")
|
||||
with socketserver.TCPServer(("127.0.0.1", 8080), http.server.SimpleHTTPRequestHandler) as httpd:
|
||||
@@ -174,6 +175,7 @@ with socketserver.TCPServer(("127.0.0.1", 8080), http.server.SimpleHTTPRequestHa
|
||||
resolved = os.path.normpath(os.path.join(os.path.dirname(page), target))
|
||||
if os.path.isdir(resolved):
|
||||
resolved = os.path.join(resolved, "index.html")
|
||||
resolved = urllib.parse.unquote(resolved)
|
||||
if not os.path.exists(resolved):
|
||||
broken.append(f"{page} -> {href}")
|
||||
assert not broken, f"broken internal links ({len(broken)}):\\n" + "\\n".join(broken[:10])
|
||||
@@ -190,11 +192,24 @@ EOS
|
||||
steps {
|
||||
withCredentials([sshUserPrivateKey(credentialsId: 'hexo_deploy_key', keyFileVariable: 'DEPLOY_KEY')]) {
|
||||
sh '''
|
||||
rsync -avz --delete --chmod=D755,F644 \\
|
||||
--exclude=.well-known/ \\
|
||||
--exclude=.user.ini \\
|
||||
-e "ssh -i $DEPLOY_KEY -o StrictHostKeyChecking=accept-new" \\
|
||||
public/ root@69.164.253.99:/www/wwwroot/leonxu260.dev/
|
||||
set -eu
|
||||
SSH="ssh -i $DEPLOY_KEY -o StrictHostKeyChecking=accept-new"
|
||||
# content hash of the built site (path + content, order-stable)
|
||||
NEW_HASH=$(find public -type f -print0 | sort -z | xargs -0 sha256sum | sha256sum | cut -d" " -f1)
|
||||
OLD_HASH=$($SSH root@69.164.253.99 cat /www/wwwroot/leonxu260.dev/.deploy-hash 2>/dev/null || echo none)
|
||||
if [ "$NEW_HASH" = "$OLD_HASH" ]; then
|
||||
echo "site content unchanged since last deploy -- skipping deploy"
|
||||
else
|
||||
echo "site changed -- deploying"
|
||||
rsync -avz --delete --chmod=D755,F644 \\
|
||||
--exclude=.well-known/ \\
|
||||
--exclude=.user.ini \\
|
||||
--exclude=.deploy-hash \\
|
||||
-e "$SSH" \\
|
||||
public/ root@69.164.253.99:/www/wwwroot/leonxu260.dev/
|
||||
echo "$NEW_HASH" | $SSH root@69.164.253.99 "cat > /www/wwwroot/leonxu260.dev/.deploy-hash"
|
||||
echo "deploy complete (stamp updated)"
|
||||
fi
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user