Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Doeunnkimm committed Jun 20, 2024
1 parent 27f5e75 commit 2de4c58
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ jobs:
with:
script: |
const targetBranch = process.env.MAIN_MERGE === 'true' ? 'main' : 'dev';
const prTitle = context.payload.pull_request.title;
const prNumber = context.payload.pull_request.number;
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
pull_number: prNumber,
merge_method: 'squash',
commit_title: `Merge pull request #${context.payload.pull_request.number} into ${targetBranch}`,
commit_title: `${prTitle} (#${prNumber})`,
commit_message: 'Auto-merging PR',
sha: context.payload.pull_request.head.sha,
base: targetBranch
});
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PUBLIC_ACCOUNT_TOKEN }}

- name: Merge Pull Request on Label
if: |
Expand All @@ -83,22 +85,24 @@ jobs:
});
const approved = reviews.some(review => review.state === 'APPROVED');
const prTitle = context.payload.pull_request.title;
const prNumber = context.payload.pull_request.number;
const targetBranch = process.env.MAIN_MERGE === 'true' ? 'main' : 'dev';
if (approved) {
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
pull_number: prNumber,
merge_method: 'squash',
commit_title: `Merge pull request #${context.payload.pull_request.number} into ${targetBranch}`,
commit_title: `${prTitle} (#${prNumber})`,
commit_message: 'Auto-merging PR',
sha: context.payload.pull_request.head.sha,
base: targetBranch
});
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PUBLIC_ACCOUNT_TOKEN }}

- name: Merge Pull Request on Unlabel
if: |
Expand All @@ -117,18 +121,20 @@ jobs:
const approved = reviews.some(review => review.state === 'APPROVED');
const labels = context.payload.pull_request.labels.map(label => label.name);
const targetBranch = labels.includes("main merge") ? 'main' : 'dev';
const prTitle = context.payload.pull_request.title;
const prNumber = context.payload.pull_request.number;
if (approved) {
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
pull_number: prNumber,
merge_method: 'squash',
commit_title: `Merge pull request #${context.payload.pull_request.number} into ${targetBranch}`,
commit_title: `${prTitle} (#${prNumber})`,
commit_message: 'Auto-merging PR',
sha: context.payload.pull_request.head.sha,
base: targetBranch
});
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PUBLIC_ACCOUNT_TOKEN }}

0 comments on commit 2de4c58

Please sign in to comment.