You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2025/05/15 04:07:29 UTC
(airflow-site) branch improve-live-staging created (now 887939cca0)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a change to branch improve-live-staging
in repository https://gitbox.apache.org/repos/asf/airflow-site.git
at 887939cca0 Update watermark processing to use python script
This branch includes the following new commits:
new 887939cca0 Update watermark processing to use python script
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(airflow-site) 01/01: Update watermark processing to use python script
Posted by po...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch improve-live-staging
in repository https://gitbox.apache.org/repos/asf/airflow-site.git
commit 887939cca0cbb23d79bca45338f8d9bac664b837
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Wed May 14 22:07:12 2025 +0100
Update watermark processing to use python script
---
.github/scripts/add_watermark.py | 81 +++++++++++++++++++++
.../static => .github/scripts}/images/staging.png | Bin
.github/workflows/build.yml | 33 ++-------
3 files changed, 88 insertions(+), 26 deletions(-)
diff --git a/.github/scripts/add_watermark.py b/.github/scripts/add_watermark.py
new file mode 100755
index 0000000000..4b811ac4e0
--- /dev/null
+++ b/.github/scripts/add_watermark.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python3
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+# /// script
+# requires-python = ">=3.11"
+# dependencies = [
+# "rich>=14.0.0",
+# ]
+# ///
+
+import shutil
+import argparse
+from pathlib import Path
+
+from rich.console import Console
+
+console = Console(width=200, color_system="standard")
+
+CSS_TO_ADD = """
+ body {
+ position: relative; /* Ensures the pseudo-element is positioned relative to the body */
+ z-index: 0; /* Keeps the content above the pseudo-element */
+ }
+
+ body::before {
+ content: "";
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: 100%;
+ height: 100%;
+ background: url(URL_PREFIX/staging.png) repeat center center fixed; /* Sets the background image */
+ opacity: 0.2; /* Makes the watermark semi-transparent */
+ pointer-events: none; /* Ensures the watermark doesn't interfere with user interactions */
+ z-index: -1; /* Places the pseudo-element behind all other elements */
+ }
+"""
+
+IMAGE_FILE=Path(__file__).parent / "images" / "staging.png"
+
+if __name__ == "__main__":
+ parser = argparse.ArgumentParser(description="Add watermark")
+ parser.add_argument("--folder", required=True, help="Folder to look for css files for")
+ parser.add_argument("--pattern", required=True, help="Glob pattern to look for")
+ parser.add_argument("--url-prefix", required=True, help="URL prefix to use for the image")
+ parser.add_argument("--image-directory", required=True,
+ help="Image directory where image should be written-relative to folder path.")
+ args = parser.parse_args()
+
+ folder_path = Path(args.folder)
+ pattern = args.pattern
+ url_prefix = args.url_prefix
+ image_directory_path = Path(args.image_directory)
+
+ content_to_add = CSS_TO_ADD.replace("URL_PREFIX", url_prefix)
+
+ files = folder_path.rglob(pattern)
+ for file in files:
+ content = file.read_text()
+ if not "watermark semi-transparent" in content:
+ console.print(f"[bright_blue]Adding watermark to:[/] {file}")
+ content = content + content_to_add
+ file.write_text(content)
+ target_image_location = folder_path / image_directory_path
+ target_image_location.mkdir(parents=True, exist_ok=True)
+ shutil.copy(IMAGE_FILE, target_image_location / "staging.png")
diff --git a/landing-pages/site/static/images/staging.png b/.github/scripts/images/staging.png
similarity index 100%
rename from landing-pages/site/static/images/staging.png
rename to .github/scripts/images/staging.png
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index ef11652df3..489b25ded4 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -141,34 +141,15 @@ jobs:
name: airflow-website
path: './dist'
if-no-files-found: error
- retention-days: 14
- - name: Apply staging modifications
+ retention-days: 7
+ - name: "Apply staging modifications: .htaccess and watermarks"
run: |
- sed -i 's/d7fnmbhf26p21.cloudfront.net/d3a2du7x0n8ydr.cloudfront.net/' .htaccess
- echo "Updated .htaccess"
- cat .htaccess
+ sed -i 's/d7fnmbhf26p21.cloudfront.net/d3a2du7x0n8ydr.cloudfront.net/' ./dist/.htaccess
+ echo "Updated ./dist/.htaccess"
+ cat ./dist/.htaccess
echo
- echo "Adding watermark"
- cat <<EOF >> ./scss/main-custom.min.*.css
- body {
- position: relative; /* Ensures the pseudo-element is positioned relative to the body */
- z-index: 0; /* Keeps the content above the pseudo-element */
- }
-
- body::before {
- content: "";
- position: fixed;
- top: 0;
- left: 0;
- width: 100%;
- height: 100%;
- background: url(/images/staging.png) repeat center center fixed; /* Sets the background image */
- opacity: 0.2; /* Makes the watermark semi-transparent */
- pointer-events: none; /* Ensures the watermark doesn't interfere with user interactions */
- z-index: -1; /* Places the pseudo-element behind all other elements */
- }
- EOF
- working-directory: ./dist
+ uv run .github/scripts/add_watermark.py --pattern 'main.min.css' \
+ --folder landing-pages/site/static --image-directory images --url-prefix /images
if: github.ref == 'refs/heads/staging'
- name: 👷 Copy .asf.yaml to /dist/
if: env.PROD_PUBLISH_REQUIRED != 'false' || env.STAGING_PUBLISH_REQUIRED != 'false'