ci: add repository guards to workflow files#364
Merged
yltx merged 11 commits intoOpenWSGR:mainfrom Mar 11, 2026
Merged
Conversation
- python-publish.yml: only run on OpenWSGR/AutoWSGR (upstream) - lunar.yml: only run on OpenWSGR/AutoWSGR (upstream) - sync-upstream.yml: re-add with fork-only guard (skip on upstream) This prevents publish from running on forks (missing PYPI_API_TOKEN) and keeps the sync workflow from running on the upstream repo.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
Fork 同步 upstream 后会获得 publish workflow,导致 fork 上也尝试发布 PyPI(因缺少 PYPI_API_TOKEN 而失败)。反过来,fork 专用的 sync-upstream workflow 之前被上游删除后也丢失了。
方案
用
if: github.repository == / !=条件守卫,让所有 workflow 文件在两个仓库中共存,但只在正确的仓库上执行:python-publish.ymlgithub.repository == 'OpenWSGR/AutoWSGR'lunar.ymlgithub.repository == 'OpenWSGR/AutoWSGR'sync-upstream.ymlgithub.repository != 'OpenWSGR/AutoWSGR'变更
python-publish.yml: 添加if限制仅在上游执行lunar.yml: 添加if限制仅在上游执行sync-upstream.yml: 重新添加,带有 fork-only 守卫条件,每 6 小时同步一次