Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Release] Stage to Main #55

Merged
merged 5 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading