Skip to content

fix(ci/preview): add custom 404 page for PR preview pages #37769

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!doctype html>
<html>
<head>
<title>404 Page Not Found</title>
<script src="/en-US/_spas/404.js"></script>
</head>
<body>
<h1>404 Page Not Found</h1>
</body>
</html>
8 changes: 8 additions & 0 deletions .github/workflows/404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
window.addEventListener("DOMContentLoaded", () => {
if (document.location.hostname.endsWith("content.dev.mdn.mozit.cloud")) {
const link = document.createElement("a");
link.href = `https://developer.mozilla.org${location.pathname}`;
link.textContent = "View on MDN production server";
document.body.appendChild(link);
}
});
5 changes: 5 additions & 0 deletions .github/workflows/pr-test-legacy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ jobs:
# Save the PR number into the build
echo ${{ github.event.number }} > ${BUILD_OUT_ROOT}/NR

# Add the custom 404 page to provide production links to the unbuilt documents
mkdir -p ${BUILD_OUT_ROOT}/en-us/_spas/
cp -v ./.github/workflows/404.html ${BUILD_OUT_ROOT}/en-us/_spas/404.html
cp -v ./.github/workflows/404.js ${BUILD_OUT_ROOT}/en-us/_spas/404.js

# Download the raw diff blob and store that inside the build
# directory.
# The purpose of this is for the PR Review Companion to later
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ jobs:
# Save the PR number into the build
echo ${{ github.event.number }} > ${BUILD_OUT_ROOT}/NR

# Add the custom 404 page to provide production links to the unbuilt documents
mkdir -p ${BUILD_OUT_ROOT}/en-us/_spas/
cp -v ./.github/workflows/404.html ${BUILD_OUT_ROOT}/en-us/_spas/404.html
cp -v ./.github/workflows/404.js ${BUILD_OUT_ROOT}/en-us/_spas/404.js

# Download the raw diff blob and store that inside the build
# directory.
# The purpose of this is for the PR Review Companion to later
Expand Down
Loading