Skip to content

Commit

Permalink
extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
danadajian committed Dec 19, 2024
1 parent 7cca779 commit d4edc53
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 18 deletions.
35 changes: 31 additions & 4 deletions dist/264.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/264.index.js.map

Large diffs are not rendered by default.

35 changes: 31 additions & 4 deletions dist/467.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/467.index.js.map

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions src/helpers/initiate-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { HelperInputs } from '../types/generated';
import { context as githubContext } from '@actions/github';
import { octokit } from '../octokit';
import { map } from 'bluebird';
import { paginateAllBranches } from '../utils/paginate-all-branches';
import { getMergeQueueCommitHashes } from '../utils/get-merge-queue-commit-hashes';

export class InitiateDeployment extends HelperInputs {
sha = '';
Expand Down Expand Up @@ -58,9 +58,7 @@ export const initiateDeployment = async ({
...GITHUB_OPTIONS
});

const branches = await paginateAllBranches();
const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/merge-queue/'));
const commitHashesForMergeQueueBranches = mergeQueueBranches.map(branch => branch.commit.sha);
const commitHashesForMergeQueueBranches = await getMergeQueueCommitHashes();
await map(commitHashesForMergeQueueBranches, async sha =>
octokit.repos.createCommitStatus({
sha,
Expand Down
6 changes: 2 additions & 4 deletions src/helpers/notify-pipeline-complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { HelperInputs } from '../types/generated';
import { context as githubContext } from '@actions/github';
import { map } from 'bluebird';
import { octokit } from '../octokit';
import { paginateAllBranches } from '../utils/paginate-all-branches';
import { getMergeQueueCommitHashes } from '../utils/get-merge-queue-commit-hashes';

export class NotifyPipelineComplete extends HelperInputs {
context?: string;
Expand All @@ -37,9 +37,7 @@ export const notifyPipelineComplete = async ({
...githubContext.repo
});
const commitHashesForOpenPullRequests = pullRequests.map(pullRequest => pullRequest.head.sha);
const branches = await paginateAllBranches();
const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/merge-queue/'));
const commitHashesForMergeQueueBranches = mergeQueueBranches.map(branch => branch.commit.sha);
const commitHashesForMergeQueueBranches = await getMergeQueueCommitHashes();
const commitHashes = commitHashesForOpenPullRequests.concat(commitHashesForMergeQueueBranches);
await map(commitHashes, async sha =>
octokit.repos.createCommitStatus({
Expand Down
20 changes: 20 additions & 0 deletions src/utils/get-merge-queue-commit-hashes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
Copyright 2022 Expedia, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

import { paginateAllBranches } from './paginate-all-branches';

export const getMergeQueueCommitHashes = async () => {
const branches = await paginateAllBranches();
const mergeQueueBranches = branches.filter(branch => branch.name.startsWith('gh-readonly-queue/merge-queue/'));
return mergeQueueBranches.map(branch => branch.commit.sha);
};

0 comments on commit d4edc53

Please sign in to comment.