Skip to content

Commit a4265a1

Browse files
Copilotmfranzke
andauthored
test: prevent dependabot to publish (#5167)
* Initial plan * Generalize bot username check to include any [bot] username * Restrict publish permission to Dependabot only * Apply suggestions from code review --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: Maximilian Franzke <787658+mfranzke@users.noreply.github.com>
1 parent 85e9643 commit a4265a1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

scripts/tests/github/get-release.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,22 @@ describe('build-gh-page', () => {
3535
"Command failed: npx --no tsx github/get-release.ts\nYour tag has to start with 'v'"
3636
);
3737
});
38+
39+
test('bot should be blocked', async () => {
40+
process.env.GITHUB_REF = 'refs/tags/v1.2.3';
41+
process.env.GITHUB_ACTOR = 'dependabot[bot]';
42+
process.env.GITHUB_COMMITISH = 'main';
43+
process.env.GITHUB_PRE_RELEASE = 'false';
44+
let result: string;
45+
try {
46+
result = execSync(command).toString();
47+
} catch (error) {
48+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
49+
result = error.message;
50+
}
51+
52+
expect(result.toString().trim()).toEqual(
53+
'Command failed: npx --no tsx github/get-release.ts\nDependabot has no permission to publish!'
54+
);
55+
});
3856
});

0 commit comments

Comments
 (0)