diff --git a/.github/workflows/auto-merge.js b/.github/workflows/auto-merge.js index 85981d29dfe3a..1c666441f32bb 100644 --- a/.github/workflows/auto-merge.js +++ b/.github/workflows/auto-merge.js @@ -47,8 +47,8 @@ module.exports = async ({ github, context }) => { repo, ref: sha, }); - return checkRuns.check_runs.every( - (run) => run.conclusion === "success" || run.conclusion === "skipped" + return checkRuns.check_runs.every(({ conclusion }) => + ["success", "skipped"].includes(conclusion) ); } @@ -71,7 +71,7 @@ module.exports = async ({ github, context }) => { for (const pr of pullRequests) { const pullRequest = await fetchPullRequestDetails(pr.number); - if (!pullRequest || pullRequest.mergeable !== true) { + if (!pullRequest?.mergeable) { console.log( `PR #${pr.number} is not mergeable or could not fetch details. Skipping this PR.` ); diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index e8b94cb3d233f..586bd0fa5e195 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -1,4 +1,4 @@ -name: Automerge PRs +name: Automerge on: schedule: @@ -9,14 +9,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout code - uses: actions/checkout@v4 - - - name: Automerge PRs with "automerge" label created within the last month and are mergeable + - uses: actions/checkout@v4 + - name: Automerge uses: actions/github-script@v6 with: github-token: ${{secrets.GITHUB_TOKEN}} retries: 3 script: | - const script = require('..github/workflows/auto-merge.js'); + const script = require('./.github/workflows/auto-merge.js'); await script({github, context}); diff --git a/.github/workflows/remove-automerge-label.yml b/.github/workflows/remove-automerge-label.yml index 82dca1697ab1b..faf7e64d78118 100644 --- a/.github/workflows/remove-automerge-label.yml +++ b/.github/workflows/remove-automerge-label.yml @@ -1,17 +1,17 @@ -name: Remove Auto-Merge Label on New Commit +name: Remove automerge label on: - pull_request: + pull_request_target: types: - synchronize jobs: remove-label: runs-on: ubuntu-latest + if: ${{ !contains(fromJSON('["OWNER", "COLLABORATOR"]'), github.event.pull_request.author_association )}} steps: - - name: Checkout code - uses: actions/checkout@v4 - - name: Remove specific label + - uses: actions/checkout@v4 + - name: Remove automerge label uses: actions/github-script@v5 with: github-token: ${{secrets.GITHUB_TOKEN}}