From a44664f821cdbb66d66c7dcb1c9662d66af789c5 Mon Sep 17 00:00:00 2001
From: OnkarRuikar <87750369+OnkarRuikar@users.noreply.github.com>
Date: Thu, 23 Jan 2025 16:36:11 +0530
Subject: [PATCH 1/7] fix(ci/preview): add custom 404 page
---
.github/workflows/404.html | 10 ++++++++++
.github/workflows/404.js | 8 ++++++++
.github/workflows/pr-test.yml | 5 +++++
3 files changed, 23 insertions(+)
create mode 100644 .github/workflows/404.html
create mode 100644 .github/workflows/404.js
diff --git a/.github/workflows/404.html b/.github/workflows/404.html
new file mode 100644
index 000000000000000..2d1ed64ede73754
--- /dev/null
+++ b/.github/workflows/404.html
@@ -0,0 +1,10 @@
+
+
+
+ 404 Page Not Found
+
+
+
+ 404 Page Not Found
+
+
diff --git a/.github/workflows/404.js b/.github/workflows/404.js
new file mode 100644
index 000000000000000..b973f7202270e41
--- /dev/null
+++ b/.github/workflows/404.js
@@ -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);
+ }
+});
diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml
index f3e8d2e5817b9c5..e592b120cac026f 100644
--- a/.github/workflows/pr-test.yml
+++ b/.github/workflows/pr-test.yml
@@ -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
From d177052314838a24f425fbbdb86a5f01b50046f2 Mon Sep 17 00:00:00 2001
From: OnkarRuikar <87750369+OnkarRuikar@users.noreply.github.com>
Date: Fri, 24 Jan 2025 10:32:05 +0530
Subject: [PATCH 2/7] apply review comments
---
.github/workflows/404.html | 2 +-
.github/workflows/404.js | 11 +++++++++--
.github/workflows/pr-test.yml | 10 +++++-----
3 files changed, 15 insertions(+), 8 deletions(-)
diff --git a/.github/workflows/404.html b/.github/workflows/404.html
index 2d1ed64ede73754..4ef2f3c043e6d44 100644
--- a/.github/workflows/404.html
+++ b/.github/workflows/404.html
@@ -2,7 +2,7 @@
404 Page Not Found
-
+
404 Page Not Found
diff --git a/.github/workflows/404.js b/.github/workflows/404.js
index b973f7202270e41..459277acaf09d38 100644
--- a/.github/workflows/404.js
+++ b/.github/workflows/404.js
@@ -1,7 +1,14 @@
+function getContentsAfterHost() {
+ const full = location.href;
+ const path = location.pathname;
+
+ return full.substring(full.indexOf(path));
+}
+
window.addEventListener("DOMContentLoaded", () => {
- if (document.location.hostname.endsWith("content.dev.mdn.mozit.cloud")) {
+ if (location.hostname.endsWith("content.dev.mdn.mozit.cloud")) {
const link = document.createElement("a");
- link.href = `https://developer.mozilla.org${location.pathname}`;
+ link.href = `https://developer.mozilla.org${getContentsAfterHost()}`;
link.textContent = "View on MDN production server";
document.body.appendChild(link);
}
diff --git a/.github/workflows/pr-test.yml b/.github/workflows/pr-test.yml
index 7049811ad24f187..3276792a30fee8e 100644
--- a/.github/workflows/pr-test.yml
+++ b/.github/workflows/pr-test.yml
@@ -112,11 +112,6 @@ 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
@@ -128,6 +123,11 @@ jobs:
run: |
# Exclude the .map files, as they're used for debugging JS and CSS.
rsync -a --exclude "*.map" node_modules/@mdn/yari/client/build/ $BUILD_OUT_ROOT
+
+ # Add the custom 404 page to provide production links to the unbuilt documents
+ cp -v ./.github/workflows/404.html ${BUILD_OUT_ROOT}/en-us/404/index.html
+ cp -v ./.github/workflows/404.js ${BUILD_OUT_ROOT}/en-us/404/index.js
+
# Show the final disk usage size of the build.
du -sh $BUILD_OUT_ROOT
From af5d62ec18719ca58331855b80729c10f0c451e5 Mon Sep 17 00:00:00 2001
From: OnkarRuikar <87750369+OnkarRuikar@users.noreply.github.com>
Date: Fri, 24 Jan 2025 10:33:30 +0530
Subject: [PATCH 3/7] test change
---
files/en-us/web/css/length/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/files/en-us/web/css/length/index.md b/files/en-us/web/css/length/index.md
index 5d9d05bbe28a600..282cd5c68333390 100644
--- a/files/en-us/web/css/length/index.md
+++ b/files/en-us/web/css/length/index.md
@@ -7,7 +7,7 @@ browser-compat: css.types.length
{{CSSRef}}
-The **``** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents a distance value. Lengths can be used in numerous CSS properties, such as {{Cssxref("width")}}, {{Cssxref("height")}}, {{Cssxref("margin")}}, {{Cssxref("padding")}}, {{Cssxref("border-width")}}, {{Cssxref("font-size")}}, and {{Cssxref("text-shadow")}}.
+The **``** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents a distance value. Lengths can be used in numerous CSS properties, such as {{Cssxref("width")}}, {{Cssxref("height")}}, {{Cssxref("margin")}}, {{Cssxref("padding")}}, {{Cssxref("border-width")}}, {{Cssxref("font-size")}}, and {{Cssxref("text-shadow")}}. test
> [!NOTE]
> Although {{cssxref("<percentage>")}} values are usable in some of the same properties that accept `` values, they are not themselves `` values. See {{cssxref("<length-percentage>")}}.
From ba4e456cd90c1897aa7cc314ea2998407b07310e Mon Sep 17 00:00:00 2001
From: OnkarRuikar <87750369+OnkarRuikar@users.noreply.github.com>
Date: Fri, 24 Jan 2025 10:41:29 +0530
Subject: [PATCH 4/7] revert test change
---
files/en-us/web/css/length/index.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/files/en-us/web/css/length/index.md b/files/en-us/web/css/length/index.md
index 282cd5c68333390..5d9d05bbe28a600 100644
--- a/files/en-us/web/css/length/index.md
+++ b/files/en-us/web/css/length/index.md
@@ -7,7 +7,7 @@ browser-compat: css.types.length
{{CSSRef}}
-The **``** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents a distance value. Lengths can be used in numerous CSS properties, such as {{Cssxref("width")}}, {{Cssxref("height")}}, {{Cssxref("margin")}}, {{Cssxref("padding")}}, {{Cssxref("border-width")}}, {{Cssxref("font-size")}}, and {{Cssxref("text-shadow")}}. test
+The **``** [CSS](/en-US/docs/Web/CSS) [data type](/en-US/docs/Web/CSS/CSS_Types) represents a distance value. Lengths can be used in numerous CSS properties, such as {{Cssxref("width")}}, {{Cssxref("height")}}, {{Cssxref("margin")}}, {{Cssxref("padding")}}, {{Cssxref("border-width")}}, {{Cssxref("font-size")}}, and {{Cssxref("text-shadow")}}.
> [!NOTE]
> Although {{cssxref("<percentage>")}} values are usable in some of the same properties that accept `` values, they are not themselves `` values. See {{cssxref("<length-percentage>")}}.
From 42afd6ac0f82030c1379bf51efc4db21f33e8ee2 Mon Sep 17 00:00:00 2001
From: OnkarRuikar <87750369+OnkarRuikar@users.noreply.github.com>
Date: Fri, 24 Jan 2025 10:46:06 +0530
Subject: [PATCH 5/7] revert changes in legacy workflow file
---
.github/workflows/pr-test-legacy.yml | 5 -----
1 file changed, 5 deletions(-)
diff --git a/.github/workflows/pr-test-legacy.yml b/.github/workflows/pr-test-legacy.yml
index 66dbdf0d1ab2139..e390e19231b95bc 100644
--- a/.github/workflows/pr-test-legacy.yml
+++ b/.github/workflows/pr-test-legacy.yml
@@ -105,11 +105,6 @@ 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
From b086d3cec33125840a5f5b999ff9b58d202e201c Mon Sep 17 00:00:00 2001
From: Onkar Khadangale <87750369+OnkarRuikar@users.noreply.github.com>
Date: Tue, 28 Jan 2025 07:35:50 +0530
Subject: [PATCH 6/7] Add a note about the rendering being a preview
---
.github/workflows/404.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/404.html b/.github/workflows/404.html
index 4ef2f3c043e6d44..eb1805252fa03ab 100644
--- a/.github/workflows/404.html
+++ b/.github/workflows/404.html
@@ -6,5 +6,6 @@
404 Page Not Found
+ Note: This is a GitHub pull request preview, and this page is not a part of the pull request.
From 4446e480236957f862d7db8056e18997fbf4f9b5 Mon Sep 17 00:00:00 2001
From: Onkar Khadangale <87750369+OnkarRuikar@users.noreply.github.com>
Date: Tue, 28 Jan 2025 07:39:26 +0530
Subject: [PATCH 7/7] remove the domain check
---
.github/workflows/404.js | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/.github/workflows/404.js b/.github/workflows/404.js
index 459277acaf09d38..427b1de2810e269 100644
--- a/.github/workflows/404.js
+++ b/.github/workflows/404.js
@@ -6,10 +6,8 @@ function getContentsAfterHost() {
}
window.addEventListener("DOMContentLoaded", () => {
- if (location.hostname.endsWith("content.dev.mdn.mozit.cloud")) {
- const link = document.createElement("a");
- link.href = `https://developer.mozilla.org${getContentsAfterHost()}`;
- link.textContent = "View on MDN production server";
- document.body.appendChild(link);
- }
+ const link = document.createElement("a");
+ link.href = `https://developer.mozilla.org${getContentsAfterHost()}`;
+ link.textContent = "View on MDN production server";
+ document.body.appendChild(link);
});