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 bf0b477 commit 8e115de
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,24 @@ jobs:
core.setOutput("auto_merge", labels.includes("auto merge"));
core.setOutput("main_merge", labels.includes("main merge"));
- name: Set Environment Variables
run: |
echo "NO_AUTO_MERGE=${{ steps.check-labels.outputs.no_auto_merge }}" >> $GITHUB_ENV
echo "AUTO_MERGE=${{ steps.check-labels.outputs.auto_merge }}" >> $GITHUB_ENV
echo "MAIN_MERGE=${{ steps.check-labels.outputs.main_merge }}" >> $GITHUB_ENV
- name: Auto Approve if Auto Merge Label Exists
if: steps.check-labels.outputs.auto_merge == 'true'
if: env.AUTO_MERGE == 'true'
uses: hmarr/auto-approve-action@v2.0.0
with:
github-token: ${{ secrets.PUBLIC_ACCOUNT_TOKEN }}

- name: Merge Pull Request on Review
if: github.event.action == 'submitted' && github.event.review.state == 'approved' && steps.check-labels.outputs.no_auto_merge == 'false'
if: github.event.action == 'submitted' && github.event.review.state == 'approved' && env.NO_AUTO_MERGE == 'false'
uses: actions/github-script@v6
with:
script: |
const targetBranch = steps.check-labels.outputs.main_merge == 'true' ? 'main' : 'dev';
const targetBranch = process.env.MAIN_MERGE === 'true' ? 'main' : 'dev';
await github.rest.pulls.merge({
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -51,7 +57,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Merge Pull Request on Label
if: github.event.action == 'labeled' && steps.check-labels.outputs.no_auto_merge == 'false'
if: github.event.action == 'labeled' && env.NO_AUTO_MERGE == 'false'
uses: actions/github-script@v6
with:
script: |
Expand All @@ -62,7 +68,7 @@ jobs:
});
const approved = reviews.some(review => review.state === 'APPROVED');
const targetBranch = steps.check-labels.outputs.main_merge == 'true' ? 'main' : 'dev';
const targetBranch = process.env.MAIN_MERGE === 'true' ? 'main' : 'dev';
if (approved) {
await github.rest.pulls.merge({
Expand Down

0 comments on commit 8e115de

Please sign in to comment.