Skip to content

Commit 9494744

Browse files
committed
improvement(ci): rename companion tags to be more descriptive
1 parent 28526dd commit 9494744

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

.github/workflows/companion-pr-check.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ jobs:
4949
const TRAILER = /Companion:\s*(?:https?:\/\/github\.com\/)?([\w.-]+)\/([\w.-]+)(?:\/pull\/|#)(\d+)/gi;
5050
const REF = /(?:https?:\/\/github\.com\/)?([\w.-]+)\/([\w.-]+)(?:\/pull\/|#)(\d+)/g;
5151
const { owner, repo } = context.repo;
52+
// Directional label: copilot/mothership PRs get "requires-sim-merge",
53+
// sim PRs get "requires-mothership-merge". Applied whenever the PR
54+
// declares a companion; removed when it declares none.
55+
const otherSide = repo === 'sim' ? 'mothership/copilot' : 'sim';
56+
const LABEL = repo === 'sim' ? 'requires-mothership-merge' : 'requires-sim-merge';
57+
const LABEL_DESC = `Has a companion PR on the ${otherSide} side — merge in lockstep`;
5258
const crossToken = process.env.CROSS_REPO_TOKEN;
5359
// Read the OTHER repo's PR via a plain REST fetch with the PAT in the
5460
// header — keeps the PAT strictly READ-ONLY and avoids re-instantiating
@@ -108,17 +114,14 @@ jobs:
108114
const ex = await findSticky(prNumber);
109115
if (ex) await github.rest.issues.deleteComment({ owner, repo, comment_id: ex.id });
110116
// Drop the label too, so a PR edited to remove all companions doesn't
111-
// keep a stale has-companion badge. 404 if not present → ignore.
112-
try { await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: 'has-companion' }); } catch {}
117+
// keep a stale badge. 404 if not present → ignore.
118+
try { await github.rest.issues.removeLabel({ owner, repo, issue_number: prNumber, name: LABEL }); } catch {}
113119
}
114120
async function ensureLabel() {
115-
try { await github.rest.issues.getLabel({ owner, repo, name: 'has-companion' }); }
121+
try { await github.rest.issues.getLabel({ owner, repo, name: LABEL }); }
116122
catch {
117123
try {
118-
await github.rest.issues.createLabel({
119-
owner, repo, name: 'has-companion', color: '5319e7',
120-
description: 'Has a cross-repo companion PR (see companion-pr-check)',
121-
});
124+
await github.rest.issues.createLabel({ owner, repo, name: LABEL, color: 'd93f0b', description: LABEL_DESC });
122125
} catch {}
123126
}
124127
}
@@ -162,7 +165,7 @@ jobs:
162165
const companions = await collectCompanions(pr);
163166
if (companions.length === 0) { await clear(pr.number); return; }
164167
await ensureLabel();
165-
try { await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: ['has-companion'] }); } catch {}
168+
try { await github.rest.issues.addLabels({ owner, repo, issue_number: pr.number, labels: [LABEL] }); } catch {}
166169
167170
const base = pr.base.ref;
168171
const lines = [];

0 commit comments

Comments
 (0)