Skip to content

Update to SDK 2.5.0 #24

Update to SDK 2.5.0

Update to SDK 2.5.0 #24

Workflow file for this run

name: Auto-merge
on:
pull_request_target:
types: ready_for_review
workflow_call:
inputs:
pr:
description: "Pull Request number"
type: number
required: true
url:
description: "Pull Request URL (HTML, not API)"
type: string
required: false
permissions:
contents: write
pull-requests: write
jobs:
approve:
continue-on-error: true
runs-on: ubuntu-latest
if: ${{ github.actor_id == github.repository_owner_id || inputs.pr }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: count requested reviewers
id: reviewers
run: |
REVIEWERS_NUM=$(echo $REQUESTED_REVIEWERS | jq '. | length')
echo "value=$REVIEWERS_NUM" >> "$GITHUB_OUTPUT"
env:
REQUESTED_REVIEWERS: ${{ toJson(github.event.pull_request.requested_reviewers) }}
- name: Linked issues
id: issues
run: |
QUERY='query ($prNumber: Int!, $repositoryName: String!, $repositoryOwner: String!) {
repository(name: $repositoryName, owner: $repositoryOwner) {
pullRequest(number: $prNumber) {
closingIssuesReferences(first: 10) {
nodes {
number
}
}
}
}
}'
ISSUES=$(gh api graphql -f query="$QUERY" -F prNumber=${{ github.event.pull_request.number || inputs.pr }} -F repositoryName=${{ github.event.repository.name }} -F repositoryOwner=${{ github.event.repository.owner.login }} -q '.data.repository.pullRequest.closingIssuesReferences.nodes[] | .number')
echo "num=$ISSUES" >> "$GITHUB_OUTPUT"
if [ -z "$ISSUES" ]
then
echo "No issues linked to this PR."
echo "have=false" >> "$GITHUB_OUTPUT"
else
echo "Issue(s) linked: $ISSUES"
echo "have=true" >> "$GITHUB_OUTPUT"
fi
# better criteria is "is this PR have only one issue and it authored by author of this PR?"
- name: Approve
# if there is no requested reviewers specified and PR don't have any linked issue's:
if: success() && steps.reviewers.outputs.value == '0'
run: gh pr review --approve "${{ github.event.pull_request.html_url || inputs.url || inputs.pr }}"
- name: Auto-merge
# only if no linked issue:
if: success() && steps.reviewers.outputs.value == '0' && steps.issues.outputs.have != 'true'
run: >-
gh pr merge --auto
--${{ github.event.pull_request.commits > 1 && 'squash' || 'merge' }}
"${{ github.event.pull_request.html_url || inputs.url || inputs.pr }}"