From 2340d4380b0e0d9c783f722116e277b231de2e38 Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Wed, 16 Sep 2026 19:49:40 +0800 Subject: [PATCH] Fix workflow and add warning to latest docker tag (#7849) --- .github/workflows/npm-update.yml | 22 ++++-- .github/workflows/release.yml | 15 ++-- .../Dockerfile.latest-warning | 8 +++ .../docker-latest-warning.js | 71 +++++++++++++++++++ extra/docker-latest-warning/package.json | 8 +++ extra/release/nightly.mjs | 4 +- 6 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 extra/docker-latest-warning/Dockerfile.latest-warning create mode 100644 extra/docker-latest-warning/docker-latest-warning.js create mode 100644 extra/docker-latest-warning/package.json diff --git a/.github/workflows/npm-update.yml b/.github/workflows/npm-update.yml index d6e313497..020c13329 100644 --- a/.github/workflows/npm-update.yml +++ b/.github/workflows/npm-update.yml @@ -17,12 +17,20 @@ jobs: permissions: contents: write pull-requests: write + strategy: + fail-fast: false + matrix: + include: + - branch: master + update_branch: npm-update + - branch: 2.5.X + update_branch: npm-update-2.5.X steps: - - name: Checkout master branch + - name: Checkout ${{ matrix.branch }} branch uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: - ref: master + ref: ${{ matrix.branch }} token: ${{ secrets.GITHUB_TOKEN }} - name: Setup Node.js @@ -59,10 +67,10 @@ jobs: git add package-lock.json git commit -m "chore: Update dependencies" - - name: Force push to npm-update branch + - name: Force push to ${{ matrix.update_branch }} branch if: steps.check_changes.outputs.has_changes == 'true' run: | - git push -f origin HEAD:npm-update + git push -f origin HEAD:${{ matrix.update_branch }} - name: Check if PR exists if: steps.check_changes.outputs.has_changes == 'true' @@ -70,7 +78,7 @@ jobs: env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - PR_EXISTS=$(gh pr list --base master --head npm-update --json number --jq 'length') + PR_EXISTS=$(gh pr list --base ${{ matrix.branch }} --head ${{ matrix.update_branch }} --json number --jq 'length') if [ "$PR_EXISTS" -eq "0" ]; then echo "pr_exists=false" >> $GITHUB_OUTPUT else @@ -83,7 +91,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | gh pr create \ - --base master \ - --head npm-update \ + --base ${{ matrix.branch }} \ + --head ${{ matrix.update_branch }} \ --title "chore: Update dependencies" \ --body "" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b22237fac..ae6badda3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,7 +4,7 @@ on: workflow_dispatch: inputs: version: - description: "Release version number (e.g., 2.1.0, or 2.1.0-beta.2 for beta)" + description: "Release version number (e.g., 2.5.5, or 2.5.5-beta.2 for beta). NOTE: Releasing 3.0.0 is NOT supported yet, this workflow currently releases the 2.5.X branch only." required: true type: string previous_version: @@ -38,8 +38,11 @@ jobs: timeout-minutes: 20 steps: + # TODO: temporarily pinned to 2.5.X because master is 3.0.0 and not ready to be released yet. + # Remove this ref (and RELEASE_BASE_BRANCH below) once 3.0.0 is ready. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + ref: 2.5.X persist-credentials: true fetch-depth: 0 # Fetch all history and tags for update-version @@ -64,6 +67,7 @@ jobs: RELEASE_VERSION: ${{ inputs.version }} RELEASE_IS_BETA: ${{ inputs.is_beta }} RELEASE_PREVIOUS_VERSION: ${{ inputs.previous_version }} + RELEASE_BASE_BRANCH: "2.5.X" DRY_RUN: ${{ inputs.dry_run }} GH_TOKEN: ${{ github.token }} GITHUB_RUN_ID: ${{ github.run_id }} @@ -76,7 +80,7 @@ jobs: outputs: pr_number: ${{ steps.pr.outputs.pr_number }} - # 2. Squash merge the release PR into master + # 2. Squash merge the release PR into the release base branch (2.5.X for now, normally master) # Re-runnable: skips if the PR is already merged merge-pr: needs: prepare @@ -121,8 +125,10 @@ jobs: timeout-minutes: 30 steps: + # TODO: temporarily pinned to 2.5.X, see the prepare job - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: + ref: 2.5.X persist-credentials: false fetch-depth: 0 # Fetch all history and tags for changelog generation @@ -142,6 +148,7 @@ jobs: RELEASE_VERSION: ${{ inputs.version }} RELEASE_IS_BETA: ${{ inputs.is_beta }} RELEASE_PREVIOUS_VERSION: ${{ inputs.previous_version }} + RELEASE_BASE_BRANCH: "2.5.X" DRY_RUN: ${{ inputs.dry_run }} MERGE_SHA: ${{ needs.merge-pr.outputs.merge_sha }} GH_TOKEN: ${{ secrets.RELEASE_PAT }} @@ -157,7 +164,7 @@ jobs: timeout-minutes: 30 steps: - # Checkout the merged master code (merge_sha), not the workflow-dispatch SHA, + # Checkout the merged release branch code (merge_sha), not the workflow-dispatch SHA, # so package.json is already bumped to the release version before building. # Otherwise the frontend FRONTEND_VERSION (from npm_package_version) would be stale. - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -195,7 +202,7 @@ jobs: path: ./tmp/dist.tar.gz retention-days: 90 - # 5. Build and push all docker images from the merged master, reusing the dist + # 5. Build and push all docker images from the merged release branch, reusing the dist # built by build-and-upload-assets (the frontend is never rebuilt here) # Re-runnable: partial pushes are overwritten safely docker-images: diff --git a/extra/docker-latest-warning/Dockerfile.latest-warning b/extra/docker-latest-warning/Dockerfile.latest-warning new file mode 100644 index 000000000..4e968eb1d --- /dev/null +++ b/extra/docker-latest-warning/Dockerfile.latest-warning @@ -0,0 +1,8 @@ +# Build and push (multi arch): +# docker buildx build -f Dockerfile.latest-warning --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:latest -t louislam/uptime-kuma:1 --push . + +FROM louislam/uptime-kuma:1.23.17-debian +COPY docker-latest-warning.js /app/dist/docker-latest-warning.js +RUN rm -f /app/dist/index.html.gz /app/dist/index.html.br \ + && sed -i 's###' /app/dist/index.html \ + && grep -q "docker-latest-warning.js" /app/dist/index.html diff --git a/extra/docker-latest-warning/docker-latest-warning.js b/extra/docker-latest-warning/docker-latest-warning.js new file mode 100644 index 000000000..2f91e3c11 --- /dev/null +++ b/extra/docker-latest-warning/docker-latest-warning.js @@ -0,0 +1,71 @@ +// Injected into the legacy `latest` / `1` Docker images. +(() => { + const isSetupPage = () => location.pathname === "/setup" || location.pathname.startsWith("/setup/"); + + let acknowledged = false; + let overlay = null; + let styleAdded = false; + + const show = () => { + if (acknowledged || overlay || !isSetupPage()) { + return; + } + + if (!styleAdded) { + const style = document.createElement("style"); + style.textContent = ".uk-latest-warning { position: fixed; inset: 0; z-index: 2147483647; }"; + document.documentElement.appendChild(style); + styleAdded = true; + } + + overlay = document.createElement("div"); + overlay.className = + "uk-latest-warning d-flex align-items-center justify-content-center p-3 bg-dark text-white overflow-auto"; + overlay.innerHTML = ` +
+

⚠️ This Uptime Kuma version is outdated!

+

+ Current Version: 1.23.17 (Outdated!) +

+

+ You are running the latest tag, which still points to Uptime Kuma v1. + It is NO LONGER maintained and does not receive any bug or security fixes. +

+

+ Please switch to a recommended tag, to get the latest version and security updates. +

+

+ Read more: + Recommended Docker Tags +

+ +
+ `; + + overlay.querySelector("button").addEventListener("click", () => { + acknowledged = true; + overlay.remove(); + overlay = null; + }); + + document.documentElement.appendChild(overlay); + }; + + // The app redirects to /setup with the client-side router, so watch for route changes. + for (const method of ["pushState", "replaceState"]) { + const original = history[method]; + history[method] = function () { + const result = original.apply(history, arguments); + show(); + return result; + }; + } + + window.addEventListener("popstate", show); + + if (document.readyState === "loading") { + document.addEventListener("DOMContentLoaded", show); + } else { + show(); + } +})(); diff --git a/extra/docker-latest-warning/package.json b/extra/docker-latest-warning/package.json new file mode 100644 index 000000000..c4da85733 --- /dev/null +++ b/extra/docker-latest-warning/package.json @@ -0,0 +1,8 @@ +{ + "name": "docker-latest-warning", + "private": true, + "scripts": { + "build": "docker build -f Dockerfile.latest-warning -t louislam/uptime-kuma:latest-warning-test .", + "multi-build-and-push": "docker buildx build -f Dockerfile.latest-warning --platform linux/amd64,linux/arm64,linux/arm/v7 -t louislam/uptime-kuma:latest -t louislam/uptime-kuma:1 --push ." + } +} diff --git a/extra/release/nightly.mjs b/extra/release/nightly.mjs index bd9014119..9a7c531ba 100644 --- a/extra/release/nightly.mjs +++ b/extra/release/nightly.mjs @@ -10,7 +10,7 @@ checkDocker(); buildDist(); // Build full image (rootless) -buildImage(repoNames, ["nightly3-rootless"], "nightly-rootless"); +buildImage(repoNames, ["nightly3-rootless", "nightly-rootless"], "nightly-rootless"); // Build full image -buildImage(repoNames, ["nightly3"], "nightly"); +buildImage(repoNames, ["nightly3", "nightly"], "nightly");