Skip to content

Commit

Permalink
feat(initiate-deployment): output deployment id (#197)
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian authored May 10, 2022
1 parent 5f729ee commit 52c9f65
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
3 changes: 2 additions & 1 deletion dist/420.index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/420.index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion src/helpers/initiate-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const initiateDeployment = async ({
...GITHUB_OPTIONS
});
const deployment_id = (data as CreateDeploymentResponse).id;
return octokit.repos.createDeploymentStatus({
await octokit.repos.createDeploymentStatus({
state,
deployment_id,
description,
Expand All @@ -51,4 +51,6 @@ export const initiateDeployment = async ({
...context.repo,
...GITHUB_OPTIONS
});

return deployment_id;
};
25 changes: 19 additions & 6 deletions test/helpers/initiate-deployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,13 @@ describe('initiateDeployment', () => {
const target_url = 'url';
const auto_merge = false;

beforeEach(() => {
initiateDeployment({
it('should call createDeployment with correct params', async () => {
await initiateDeployment({
sha,
environment,
description,
target_url
});
});

it('should call createDeployment with correct params', () => {
expect(octokit.repos.createDeployment).toHaveBeenCalledWith({
ref: sha,
environment,
Expand All @@ -64,7 +61,13 @@ describe('initiateDeployment', () => {
});
});

it('should call createDeploymentStatus with correct params', () => {
it('should call createDeploymentStatus with correct params', async () => {
await initiateDeployment({
sha,
environment,
description,
target_url
});
expect(octokit.repos.createDeploymentStatus).toHaveBeenCalledWith({
state: 'in_progress',
deployment_id,
Expand All @@ -74,4 +77,14 @@ describe('initiateDeployment', () => {
...GITHUB_OPTIONS
});
});

it('should return deployment id as output', async () => {
const result = await initiateDeployment({
sha,
environment,
description,
target_url
});
expect(result).toEqual(deployment_id);
});
});

0 comments on commit 52c9f65

Please sign in to comment.