docs: add more examples

Signed-off-by: Kurt King <kurtaking@gmail.com>
This commit is contained in:
Kurt King
2023-08-05 18:13:37 -06:00
parent 2e7c770cda
commit 563b8443e9
2 changed files with 89 additions and 1 deletions
@@ -132,4 +132,61 @@ describe('github:repo:create examples', () => {
visibility: 'private',
});
});
it('should call the githubApis with a description for createInOrg', async () => {
mockOctokit.rest.users.getByUsername.mockResolvedValue({
data: { type: 'Organization' },
});
mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} });
await action.handler({
...mockContext,
input: yaml.parse(examples[1].example).steps[0].input,
});
expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({
name: 'repo',
description: 'My new repository',
org: 'owner',
private: true,
delete_branch_on_merge: false,
allow_squash_merge: true,
squash_merge_commit_title: 'COMMIT_OR_PR_TITLE',
squash_merge_commit_message: 'COMMIT_MESSAGES',
allow_merge_commit: true,
allow_rebase_merge: true,
allow_auto_merge: false,
visibility: 'private',
});
});
it('should call the githubApis with wiki and issues disabled for createInOrg', async () => {
mockOctokit.rest.users.getByUsername.mockResolvedValue({
data: { type: 'Organization' },
});
mockOctokit.rest.repos.createInOrg.mockResolvedValue({ data: {} });
await action.handler({
...mockContext,
input: yaml.parse(examples[2].example).steps[0].input,
});
expect(mockOctokit.rest.repos.createInOrg).toHaveBeenCalledWith({
name: 'repo',
org: 'owner',
private: true,
delete_branch_on_merge: false,
allow_squash_merge: true,
squash_merge_commit_title: 'COMMIT_OR_PR_TITLE',
squash_merge_commit_message: 'COMMIT_MESSAGES',
allow_merge_commit: true,
allow_rebase_merge: true,
allow_auto_merge: false,
visibility: 'private',
has_issues: false, // disable issues
has_wiki: false, // disable wiki
});
});
});
@@ -19,7 +19,7 @@ import yaml from 'yaml';
export const examples: TemplateExample[] = [
{
description: 'Creates a GitHub repository.',
description: 'Creates a GitHub repository with default configuration.',
example: yaml.stringify({
steps: [
{
@@ -32,4 +32,35 @@ export const examples: TemplateExample[] = [
],
}),
},
{
description: 'Add a description.',
example: yaml.stringify({
steps: [
{
action: 'github:repo:create',
name: 'Create a new GitHub repository',
input: {
repoUrl: 'github.com?repo=repo&owner=owner',
description: 'My new repository',
},
},
],
}),
},
{
description: 'Disable wiki and issues.',
example: yaml.stringify({
steps: [
{
action: 'github:repo:create',
name: 'Create a new GitHub repository',
input: {
repoUrl: 'github.com?repo=repo&owner=owner',
hasIssues: false,
hasWiki: false,
},
},
],
}),
},
];