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:37:19 UTC

(airflow-site) branch staging updated (9ffd7c6341 -> 8a83ffa324)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a change to branch staging
in repository https://gitbox.apache.org/repos/asf/airflow-site.git


 discard 9ffd7c6341 Update watermark processing to use python script
     new 8a83ffa324 Update watermark processing to use python script

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (9ffd7c6341)
            \
             N -- N -- N   refs/heads/staging (8a83ffa324)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

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.


Summary of changes:
 .github/workflows/build.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


(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 staging
in repository https://gitbox.apache.org/repos/asf/airflow-site.git

commit 8a83ffa3247af266319aa06e5b756e3ad93ab066
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                        |  35 +++------
 3 files changed, 90 insertions(+), 26 deletions(-)

diff --git a/.github/scripts/add_watermark.py b/.github/scripts/add_watermark.py
new file mode 100755
index 0000000000..2aad7aa764
--- /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..4fa0bed382 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -141,34 +141,16 @@ 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
+          set -x
+          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'
@@ -195,6 +177,7 @@ jobs:
           git config user.email "actions@users.noreply.github.com"
           echo "Running git add"
           git add .
+          git diff HEAD
           echo "Running git commit"
           git commit --no-edit -m "Docs updated via ${{ github.ref }}:${{ github.sha }}" > ../git_commit.log
           echo "Running git push to ${{ env.PUBLISH_BRANCH }} branch"