Skip to content

Commit

Permalink
Merge pull request #55 from mokimo/stage
Browse files Browse the repository at this point in the history
[Release] Stage to Main
  • Loading branch information
mokimo authored Apr 29, 2024
2 parents 678bea1 + cd8d194 commit c28500d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/merge-to-stage.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const getPRs = async () => {
};

const merge = async ({ prs }) => {
console.log(`Merging ${prs.length} PRs that are ready... `);
console.log(`Merging ${prs.length || 0} PRs that are ready... `);
for await (const { number, files, html_url, title } of prs) {
if (files.some((file) => seen[file])) {
await slackNotification(slack.fileOverlap({ html_url, number, title }));
Expand All @@ -135,6 +135,7 @@ const merge = async ({ prs }) => {
files.forEach((file) => (seen[file] = true));
if (!process.env.LOCAL_RUN)
await github.rest.pulls.merge({ owner, repo, pull_number: number });
body = `- [${title}](${html_url})\n${body}`;
await slackNotification(slack.merge({ html_url, number, title }));
}
};
Expand All @@ -158,7 +159,6 @@ const openStageToMainPR = async () => {
head: stage,
});

const seenPRs = new Set();
for (const commit of comparisonData.commits) {
const { data: pullRequestData } =
await github.rest.repos.listPullRequestsAssociatedWithCommit({
Expand All @@ -168,10 +168,8 @@ const openStageToMainPR = async () => {
});

for (const pr of pullRequestData) {
if (!seenPRs.has(pr.html_url)) {
if (!body.includes(pr.html_url))
body = `- [${pr.title}](${pr.html_url})\n${body}`;
seenPRs.add(pr.html_url);
}
}
}

Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/merge-to-stage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ jobs:
const event = JSON.parse(fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8'));
if (process.env.GITHUB_EVENT_NAME === 'pull_request') {
const { label: { name } } = event;
return name === 'Ready for Stage';
if (name !== 'Ready for Stage') {
console.log('Label is not "Ready for Stage", stopping workflow...');
return false;
}
}
return true;
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Merge to stage or queue to merge
if: steps.check_label.outputs.result == 'true'
uses: actions/[email protected]
with:
script: |
Expand Down

0 comments on commit c28500d

Please sign in to comment.