Skip to content
git-pull-request

GitHub Action

Commits Range Action

v1.0.1 Latest version

Commits Range Action

git-pull-request

Commits Range Action

Gets a range of commits and their related pull requests

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Commits Range Action

uses: arikmaor/[email protected]

Learn more about this action in arikmaor/commits-range-action

Choose a version

typescript-action status

Commits range action

Gets a list of commits that were added or removed (by running git log internally) along with their related pull requests.

Useful for reporting during deployments which PRs are being deployed and which are rolled-back

Basic Usage:

Add this action as a step to your project's GitHub Action Workflow file:

steps:
  - uses: actions/checkout@v2
    with:
      fetch-depth: 0 # we must specify this to checkout all the branches
  - name: Get deployed revision
    id: get_rev
    run: |
      # get the deployed revision somehow, depends on your deployment
      # export it to a step output
      echo "::set-output name=deployed_rev::$DEPLOYED_REV"
  - uses: arikmaor/commits-range-action@v1
    id: commit_data
    with:
      github_token: ${{ secrets.GITHUB_TOKEN }}
      base_revision: ${{ steps.get_rev.outputs.deployed_rev }}
  - name: Print result
    env:
      RESULT: ${{ steps.commit_data.outputs.result }}
    run: echo $RESULT | jq

The result is a json that implements the following interface:

interface Result {
  headOnlyCommits: CommitDetails[]
  headOnlyPullRequests: PullRequestDetails[]
  baseOnlyCommits: CommitDetails[]
  baseOnlyPullRequests: PullRequestDetails[]
}

interface CommitDetails {
  oid: string
  abbreviatedOid: string
  messageHeadline: string
  message: string
  url: string
  associatedPullRequests: PullRequestDetails[]
}

interface PullRequestDetails {
  number: number
  title: string
  url: string
  labels: string[]
  body: string
  closed: boolean
  merged: boolean
  isDraft: boolean
  createdAt: string
  author: string
}