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

OCC-113: Add variable merge method support #156

Merged
merged 3 commits into from
Dec 23, 2022
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
12 changes: 10 additions & 2 deletions .github/actions/auto-merge-pull-request/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ description: >
Merges the current pull request automatically if the "merge-and-resolve-jira-issue-if-checks-succeed" or
"merge-if-checks-succeed" label is present.

inputs:
merge-method:
required: false
default: merge
description: >
The merge strategy to be used. See the API documentation for "merge_method" for applicable values:
https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#merge-a-pull-request

runs:
using: "composite"
steps:
Expand All @@ -24,8 +32,8 @@ runs:
if: steps.check-mergeability.outputs.contains-label == 'true'
shell: pwsh
run: |
$url = "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge"
Invoke-WebRequest $url -Headers (Get-GitHubApiAuthorizationHeader) -Method Put
$url = '/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/merge'
gh api --method PUT $url --raw-field merge_method='${{ inputs.merge-method }}'

- name: Remove Label
if: steps.check-mergeability.outputs.contains-label == 'true'
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/post-pull-request-checks-automation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ on:
required: true
description: Configure as explained under https://github.com/marketplace/actions/jira-login#enviroment-variables.

inputs:
merge-method:
description: >
The merge strategy to be used for the auto-merge-pull-request action. See the API documentation for
"merge_method" for applicable values: https://docs.github.com/en/rest/pulls/pulls?apiVersion=2022-11-28#merge-a-pull-request
required: false
type: string
default: merge

jobs:
post-pull-request-checks-automation:
runs-on: ubuntu-22.04
Expand All @@ -42,9 +51,11 @@ jobs:
"MERGE_TOKEN=$mergeToken" >> $Env:GITHUB_ENV

- name: Automatically Merge Pull Request
uses: Lombiq/GitHub-Actions/.github/actions/auto-merge-pull-request@dev
uses: Lombiq/GitHub-Actions/.github/actions/auto-merge-pull-request@issue/OCC-113
env:
GITHUB_TOKEN: ${{ env.MERGE_TOKEN }}
with:
merge-method: ${{ inputs.merge-method }}

- name: Automatically Resolve or Done Jira issue
uses: Lombiq/GitHub-Actions/.github/actions/auto-resolve-done-jira-issue@dev
Expand Down