A GitHub Action that provides detailed information about the triggering pull requests for workflow events, enhancing what's available from the standard GitHub context.
To use this GitHub Action, you need to create a workflow file (e.g., .github/workflows/get-information.yml
) in your repository. Here's an example workflow:
name: Get information
on:
pull_request:
branches: ['main']
jobs:
info:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Get origin information
uses: thedaviddias/[email protected]
outputs:
pullRequestNumber: ${{ steps.workflow-run-info.outputs.pullRequestNumber }}
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
`Workflow Origin' action gives you details about the pull requests that kick-started the workflow for the pull_request, pull_request_review, and workflow_run events. These events usually need more source run information than what GitHub context directly gives you.
Think of it like this - if your workflow starts because of a pull request, you might want to know about the merge commit produced by that pull request or any labels tied to the Pull Request. This action provides outputs for this kind of data. It's best to place this action first in your workflow sequence. Then, you can access its outputs using the 'needs' dependency.
For the pull_request event, don't specify the sourceRunId input. However, for the workflow_run event, you should set sourceRunId to ${{ github.event.workflow_run.id }}.
Input name | Required | Default | Description |
---|---|---|---|
github_token |
yes | Token to use to authorize label changes. Typically the GITHUB_TOKEN secret | |
sourceRunId |
no | In case of workflow_run event it should be set to ${{ github.event.workflow_run.id }} |
Output name | No sourceRunId specified |
The sourceRunId set to ${{ github.event.workflow_run.id }} |
---|---|---|
pullRequestNumber |
Number of the associated Pull Request (if PR triggered) | Number of the associated Pull Request (if PR triggered) |
name: Get information
on:
pull_request:
branches: ['main']
jobs:
info:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Release Notification
uses: thedaviddias/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
The current action is inspired by Get Workflow Origin which unfortunately didn't seem active enough.
This GitHub Action is licensed under the MIT License.