From 7e0d498a589299262792f438203b0d9398d6ab20 Mon Sep 17 00:00:00 2001 From: Cristiano Betta Date: Wed, 7 Oct 2020 14:52:05 +0100 Subject: [PATCH] Add ability to change merge method * Add input option to action.yml, defining new possible values and default value * Read new input in JS and pass desired merge method to Oktokit * Update documentation to highlight new input option Re #25 --- README.md | 4 ++++ action.yml | 7 +++++++ lib/handle_schedule.js | 3 +++ 3 files changed, 14 insertions(+) diff --git a/README.md b/README.md index 7b25357..f5f41d1 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: gr2m/merge-schedule-action@v1.x + with: + # Merge method to use. Possible values are merge, squash or + # rebase. Default is merge. + merge_method: squash env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} ``` diff --git a/action.yml b/action.yml index af9d027..ba38194 100644 --- a/action.yml +++ b/action.yml @@ -6,3 +6,10 @@ branding: runs: using: "node12" main: "dist/index.js" +inputs: + merge_method: + description: |- + Merge method to use. Possible values are `merge`, `squash` or + `rebase`. Default is `merge`. + required: false + default: merge diff --git a/lib/handle_schedule.js b/lib/handle_schedule.js index 5f28464..e3b9054 100644 --- a/lib/handle_schedule.js +++ b/lib/handle_schedule.js @@ -12,6 +12,8 @@ async function handleSchedule() { const eventPayload = require(process.env.GITHUB_EVENT_PATH); + const mergeMethod = process.env.INPUT_MERGE_METHOD + core.info(`Loading open pull request`); const pullRequests = await octokit.paginate( "GET /repos/:owner/:repo/pulls", @@ -56,6 +58,7 @@ async function handleSchedule() { owner, repo, pull_number: pullRequest.number, + merge_method: mergeMethod }); // find check runs by the Merge schedule action