thedaviddias / workflow-origin-action

GitHub Action that provides detailed information about the triggering pull requests for workflow events

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Workflow origin (Action)

Check dist/ Build tests

A GitHub Action that provides detailed information about the triggering pull requests for workflow events, enhancing what's available from the standard GitHub context.

Usage

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/workflow-origin-action@vX.X.X
        outputs:
          pullRequestNumber: ${{ steps.workflow-run-info.outputs.pullRequestNumber }}
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

Description

`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 }}.

Inputs

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 }}

Outputs

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)

Examples

Example Workflow (Minimum Configuration)

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/workflow-origin-action@vX.X.X
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}

Inspiration

The current action is inspired by Get Workflow Origin which unfortunately didn't seem active enough.

Contributors

Licence

This GitHub Action is licensed under the MIT License.

About

GitHub Action that provides detailed information about the triggering pull requests for workflow events

License:MIT License


Languages

Language:TypeScript 96.5%Language:JavaScript 3.5%