Skip to content

Commit 30d5175

Browse files
gr2mpvdlg
authored andcommitted
feat: GitHub Actions support
1 parent 543e7d6 commit 30d5175

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

lib/verify.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const VALIDATORS = {
2727

2828
module.exports = async (pluginConfig, context) => {
2929
const {
30+
env,
3031
options: {repositoryUrl},
3132
logger,
3233
} = context;
@@ -52,6 +53,14 @@ module.exports = async (pluginConfig, context) => {
5253
} else if (githubToken && !errors.find(({code}) => code === 'EINVALIDPROXY')) {
5354
const github = getClient({githubToken, githubUrl, githubApiPathPrefix, proxy});
5455

56+
// https://github.com/semantic-release/github/issues/182
57+
// Do not check for permissions in GitHub actions, as the provided token is an installation access token.
58+
// github.repos.get({repo, owner}) does not return the "permissions" key in that case. But GitHub Actions
59+
// have all permissions required for @semantic-release/github to work
60+
if (env.GITHUB_ACTION) {
61+
return;
62+
}
63+
5564
try {
5665
const {
5766
data: {

test/verify.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,26 @@ test.serial('Verify "assignees" is a String', async t => {
323323
t.true(github.isDone());
324324
});
325325

326+
// https://github.com/semantic-release/github/issues/182
327+
test.serial('Verify if run in GitHub Action', async t => {
328+
const owner = 'test_user';
329+
const repo = 'test_repo';
330+
const env = {GITHUB_TOKEN: 'v1.1234567890123456789012345678901234567890', GITHUB_ACTION: 'Release'};
331+
const proxy = 'https://localhost';
332+
const assets = [{path: 'lib/file.js'}, 'file.js'];
333+
const successComment = 'Test comment';
334+
const failTitle = 'Test title';
335+
const failComment = 'Test comment';
336+
const labels = ['semantic-release'];
337+
338+
await t.notThrowsAsync(
339+
verify(
340+
{proxy, assets, successComment, failTitle, failComment, labels},
341+
{env, options: {repositoryUrl: `git+https://othertesturl.com/${owner}/${repo}.git`}, logger: t.context.logger}
342+
)
343+
);
344+
});
345+
326346
test('Throw SemanticReleaseError for missing github token', async t => {
327347
const [error] = await t.throwsAsync(
328348
verify(

0 commit comments

Comments
 (0)