mirror of
https://github.com/tiennm99/loto.git
synced 2026-09-02 20:24:56 +00:00
ci: GitHub Pages now serves a redirect to loto.miti99.com
Replace the full build+publish flow with a tiny inline shell step that emits two static HTML pages (out/index.html and out/master/index.html). Each one carries: <meta http-equiv="refresh" content="0; url=https://loto.miti99.com/"> <script>location.replace("https://loto.miti99.com" + ...)</script> The script preserves path / query / hash, so /loto/ → loto.miti99.com/ /loto/master → loto.miti99.com/master /loto/?x=1 → loto.miti99.com/?x=1 Cloudflare Pages stays canonical; this change just stops GH Pages from serving a stale duplicate of the app and points old links at the live domain instead. The build:gh npm script is kept as a manual escape hatch for the rare case where someone wants to deploy a real GH Pages copy by hand.
This commit is contained in:
+35
-8
@@ -1,4 +1,4 @@
|
||||
name: Deploy to GitHub Pages
|
||||
name: Deploy redirect to GitHub Pages
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -19,16 +19,43 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 20
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run build:gh
|
||||
- name: Generate redirect pages
|
||||
run: |
|
||||
set -euo pipefail
|
||||
DEST="https://loto.miti99.com"
|
||||
mkdir -p out/master
|
||||
cat > out/index.html <<HTML
|
||||
<!doctype html>
|
||||
<html lang="vi">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Lô tô — đã chuyển sang ${DEST}</title>
|
||||
<link rel="canonical" href="${DEST}/">
|
||||
<meta http-equiv="refresh" content="0; url=${DEST}/">
|
||||
<meta name="robots" content="noindex">
|
||||
<script>
|
||||
(function () {
|
||||
var path = location.pathname.replace(/^\/loto/, "");
|
||||
location.replace("${DEST}" + path + location.search + location.hash);
|
||||
})();
|
||||
</script>
|
||||
<style>
|
||||
body { font-family: system-ui, sans-serif; padding: 3rem 1.5rem; text-align: center; color: #475569; }
|
||||
a { color: #6366f1; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<p>Trang đã chuyển sang <a href="${DEST}/">${DEST}</a></p>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
# Mirror to /master so deep links also redirect cleanly
|
||||
cp out/index.html out/master/index.html
|
||||
- uses: actions/configure-pages@v5
|
||||
- uses: actions/upload-pages-artifact@v3
|
||||
with:
|
||||
path: build
|
||||
path: out
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
|
||||
Reference in New Issue
Block a user