You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asyncband.apache.org by ti...@apache.org on 2026/09/03 13:59:18 UTC
(asyncband-site) branch preview/cleanup-staging created (now b45045a)
This is an automated email from the ASF dual-hosted git repository.
tisonkun pushed a change to branch preview/cleanup-staging
in repository https://gitbox.apache.org/repos/asf/asyncband-site.git
at b45045a ci: delete the staging branch when a preview pull request closes
This branch includes the following new commits:
new b45045a ci: delete the staging branch when a preview pull request closes
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.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org
(asyncband-site) 01/01: ci: delete the staging branch when a preview pull request closes
Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
tisonkun pushed a commit to branch preview/cleanup-staging
in repository https://gitbox.apache.org/repos/asf/asyncband-site.git
commit b45045a4ba5846f82aae9700aed7b740f5ebcb0a
Author: tison <wa...@gmail.com>
AuthorDate: Thu Sep 3 21:59:08 2026 +0800
ci: delete the staging branch when a preview pull request closes
The deploy workflow publishes every preview/<name> build to a generated
site/<name>-staging branch, and nothing removed those branches or their
staged sites afterwards. Add a cleanup-staging workflow that deletes the
matching site/<name>-staging branch when a preview pull request closes,
whether merged or not, and document the behavior in AGENTS.md.
---
.github/workflows/cleanup-staging.yml | 49 +++++++++++++++++++++++++++++++++++
AGENTS.md | 1 +
staging-cleanup-proposal.md | 36 +++++++++++++++++++++++++
3 files changed, 86 insertions(+)
diff --git a/.github/workflows/cleanup-staging.yml b/.github/workflows/cleanup-staging.yml
new file mode 100644
index 0000000..0637f45
--- /dev/null
+++ b/.github/workflows/cleanup-staging.yml
@@ -0,0 +1,49 @@
+# 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.
+
+name: Cleanup staging
+
+on:
+ pull_request:
+ types:
+ - closed
+
+permissions:
+ contents: write
+
+jobs:
+ cleanup:
+ name: Delete staging branch
+ runs-on: ubuntu-latest
+ # The preview is over once the pull request is closed, merged or not.
+ if: >-
+ startsWith(github.event.pull_request.head.ref, 'preview/') && github.event.pull_request.head.repo.full_name == github.repository
+ steps:
+ - name: Delete the site/<name>-staging branch if it exists
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ HEAD_REF: ${{ github.event.pull_request.head.ref }}
+ REPOSITORY: ${{ github.repository }}
+ run: |
+ name="${HEAD_REF#preview/}"
+ staging_branch="site/${name}-staging"
+ if gh api "repos/${REPOSITORY}/git/ref/heads/${staging_branch}" --silent; then
+ gh api -X DELETE "repos/${REPOSITORY}/git/refs/heads/${staging_branch}"
+ echo "Deleted ${staging_branch}."
+ else
+ echo "No ${staging_branch} branch; nothing to do."
+ fi
diff --git a/AGENTS.md b/AGENTS.md
index 3b9fabc..37b226b 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -17,4 +17,5 @@
- Push the `preview/<name>` branch before opening the pull request. The deploy workflow publishes its build to the generated `site/<name>-staging` branch and ASF serves it at `https://asyncband-<name>.staged.apache.org/`.
- Treat `site/<name>-staging` as deployment output. Never base work on it, commit to it directly, or use it as the pull request head branch.
- Open the pull request from `preview/<name>` into `main` and include the staging URL in the pull request description.
+- When the pull request is closed, the cleanup workflow deletes the `site/<name>-staging` branch and its staged preview goes offline. To remove a stale staging preview by hand, delete its `site/<name>-staging` branch.
- Production publishing remains separate: pushes to `main` publish through the `asf-site` branch.
diff --git a/staging-cleanup-proposal.md b/staging-cleanup-proposal.md
new file mode 100644
index 0000000..371e119
--- /dev/null
+++ b/staging-cleanup-proposal.md
@@ -0,0 +1,36 @@
+# Staging 残留清理方案(本地评审稿,不入库)
+
+## 现状(已核实)
+
+- 合并 PR 后,`preview/<name>` 源分支会被 GitHub 自动删除(`.asf.yaml` 里 `del_branch_on_merge: true` 生效中),这一侧没有残留。
+- 真正残留的是 Deploy workflow 产出的部署分支 `site/<name>-staging`。目前远程有 3 个:`site/docusaurus-staging`(PR #8,已合并)、`site/homepage-staging`(PR #9,已合并)、`site/readme-homepage-staging`(PR #7,关闭未合并),对应的 `https://asyncband-<name>.staged.apache.org/` 全部仍在对外服务(HTTP 200)。
+- ASF 的 `autostage: site/*` 是按分支提供 staging 内容的;分支删除后预览站即下线(asfyaml 文档未明示删除语义,需首次清理时实测验证)。
+- 现有 ruleset 只保护 `main` 和 `asf-site`,`site/*` 分支可以安全删除。
+
+## 方案 A:手动清理 + 文档约定(改动最小)
+
+- 每次合并/关闭 preview PR 后,手动执行 `git push origin --delete site/<name>-staging`。
+- 在 `AGENTS.md` 的 preview 流程说明里补上这一步,作为流程的一部分。
+- 优点:不加任何自动化,没有维护负担;删除动作显式可控。
+- 缺点:靠人记,忘了就残留;staging 站点在删除前一直在线。
+
+## 方案 B:PR 关闭时自动清理(推荐)
+
+- 新增 `.github/workflows/cleanup-staging.yml`,触发条件 `pull_request: types: [closed]`。
+- 逻辑:若 PR 头分支匹配 `preview/*` 且来自本仓库(排除 fork),则推导 `site/<name>-staging`,存在即用 `GITHUB_TOKEN` 删除(`contents: write`)。
+- 合并和关闭未合并两种情况都清理——预览周期都已结束(PR #7 就是关闭未合并也留下了残留)。
+- 整个 workflow 约 20 行 YAML,无新依赖。
+- 优点:全自动、作用域精确、与 AGENTS.md 已有的分支命名约定天然对齐。
+- 缺点:依赖命名约定;分支删除事件本身不会再触发其他流程,无连锁风险。
+
+## 方案 C:定时清扫(janitor)
+
+- 新增一个按周运行的 schedule workflow:列出所有 `site/*-staging` 分支,删掉没有对应打开状态 `preview/<name>` PR 的分支。
+- 优点:能兜住所有途径产生的残留(包括手动乱推的分支)。
+- 缺点:逻辑更复杂(要用 GitHub API 反查打开中的 PR);残留最长可存活一周;多一个定时任务要维护。
+
+## 建议
+
+选 **方案 B**:它和现有的 preview 工作流正好互补,自动化程度够且最简单;方案 A 可以作为 B 的文档补充写进 AGENTS.md(说明自动清理的存在和手动清理方法)。
+
+无论选哪个,都需要一次性清掉现有的 3 个残留分支:`site/docusaurus-staging`、`site/homepage-staging`、`site/readme-homepage-staging`,并实测 staging 站点随分支删除而下线。
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@asyncband.apache.org
For additional commands, e-mail: commits-help@asyncband.apache.org