From 8417d2c078c1eeb1fd80544707f317b9991186c0 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 12 Aug 2025 11:55:04 -0400 Subject: [PATCH] .github: only run redmine-upkeep actions from ceph/ceph.git Signed-off-by: Patrick Donnelly --- .github/workflows/redmine-upkeep.yml | 3 ++- src/script/redmine-upkeep.py | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/redmine-upkeep.yml b/.github/workflows/redmine-upkeep.yml index 58aab58945cba..11400145ee493 100644 --- a/.github/workflows/redmine-upkeep.yml +++ b/.github/workflows/redmine-upkeep.yml @@ -37,7 +37,8 @@ concurrency: jobs: redmine-upkeep: runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/redmine-upkeep' + # This condition ensures the job only runs in the main ceph/ceph repository and only on the specified branches. + if: github.repository == 'ceph/ceph' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/redmine-upkeep') permissions: # To allow writing comments on PRs: issues: write diff --git a/src/script/redmine-upkeep.py b/src/script/redmine-upkeep.py index f8b30042d7df7..4a7f1a010a8e5 100755 --- a/src/script/redmine-upkeep.py +++ b/src/script/redmine-upkeep.py @@ -48,9 +48,7 @@ GITHUB_RUN_ID = os.getenv("GITHUB_RUN_ID", "nil") GITHUB_ACTION_LOG = f"{GITHUB_SERVER_URL}/{GITHUB_REPOSITORY}/actions/runs/{GITHUB_RUN_ID}" GITHUB_USER = os.getenv("GITHUB_USER", os.getenv("GITHUB_USER", getuser())) -GITHUB_ORG = "ceph" -GITHUB_REPO = "ceph" -GITHUB_API_ENDPOINT = f"https://api.github.com/repos/{GITHUB_ORG}/{GITHUB_REPO}" +GITHUB_API_ENDPOINT = f"https://api.github.com/repos/{GITHUB_REPOSITORY}" REDMINE_CUSTOM_FIELD_ID_BACKPORT = 2 REDMINE_CUSTOM_FIELD_ID_RELEASE = 16 @@ -1400,6 +1398,10 @@ def main(): log.fatal("REDMINE_API_KEY not found! Please set REDMINE_API_KEY environment variable or ~/.redmine_key.") sys.exit(1) + if IS_GITHUB_ACTION and GITHUB_REPOSITORY != "ceph/ceph": + log.fatal("refusing to run ceph/ceph.git github action for repository {GITHUB_REPOSITORY}") + sys.exit(0) + RU = None try: RU = RedmineUpkeep(args) -- 2.39.5