Skip to content

Skenvy/dispatch-suggestor

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

95 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Test Action Tests OpenSSF Scorecard

See it on the πŸͺ marketplace.


Suggests dispatchable workflows for a branch that would otherwise trigger the dispatchable workflows from pushes to the trunk.

- name: Dispatch πŸ“€ Suggestor πŸ“₯
  uses: Skenvy/dispatch-suggestor@v1
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}

Embed the action in a workflow triggered on pull_request events, and it will determine a list of workflows with workflow_dispatch triggers that would also be triggered on push to the trunk branch (but that aren't triggered by pushing to the PR's head branch).

E.g. if you have several workflow_dispatch based workflows that are each also triggered by pushes to the trunk branch but limited to specific file triggers, this action will evaluate the changes in the PR and determine for each dispatchable workflow if they are relevant or not, and then suggest the ones it considers relevant.

Inputs

github_token

  • Required
  • Requires that the workflow or job have permissions set to at least
    permissions:
      actions: read
      contents: read
      pull-requests: write

trunk-branch

  • Optional
  • Name of the trunk branch, if not main.
  • Default 'main'.

checkout-root

  • Optional
  • The path to the root folder of the checked out repo, relative to the default working-directory, $GITHUB_WORKSPACE. It should be the same as the value provided to @actions/checkout with.path:, or default.
  • Default '.'.

list-workflows-pagination-limit

  • Optional
  • The maximum number of workflows to paginate over from the list-repository-workflows API. An input of 0 will retrieve all.
  • Default 100.

Inputs -- more niche options

comment-unique-identifier

  • Optional
  • A hidden string the action can use to identify any previously written comment, to edit it rather than add indefinitely. Only useful if you're using this action with multiple configurations on the same PR.
  • Default 'DEFAULT_COMMENT_UNIQUE_IDENTIFIER'.

inject-diff-paths

  • Optional
  • A comma-separated list of paths to inject into the list of changed files.
  • Default ''.

Inputs -- logging options

log-event-payload

  • Optional
  • If not false, will print the whole triggering event payload.
  • Default 'false'.

log-workflow-triggers

  • Optional
  • If not false, will print the triggers for all dispatchable workflows.
  • Default 'false'.

vvv

  • Optional
  • Very very verbose. Include debugging logs.
  • Default 'false'.

Outputs

list-of-changed-files

  • A list of the files that have been touched by this PR.

list-of-dispatchable-workflows

  • A list of the workflows found in this repo that have workflow_dispatch triggers.

Example Usage

The recommended on: to use for the workflow

  • For a deployment_branch of main.
  • Use on.pull_request.paths-ignore if there're any paths you're certain won't ever trigger any other workflow.
on:
  pull_request:
    branches:
    - 'main'

Checkout: In jobs.<job_id>.steps[*]

  • Prior to the uses: Skenvy/dispatch-suggestor@v1 step, you'll need to checkout, as this action checks the local state of workflows.
- name: 🏁 Checkout
  uses: actions/checkout@v4
  with:
    sparse-checkout: |
      .github/workflows/*.y*ml
    sparse-checkout-cone-mode: false

this: In jobs.<job_id>.steps[*].uses:

  • With the deployment branch being main, and the checkout above, in the least decorated way;
- uses: Skenvy/dispatch-suggestor@v1
  with:
    github_token: ${{ secrets.GITHUB_TOKEN }}

A complete example

See this example here.

example workflow badge

name: Dispatch πŸ“€ Suggestor πŸ“₯
on:
  pull_request:
permissions:
  actions: read
  contents: read
  pull-requests: write
jobs:
  suggestor:
    name: Dispatch πŸ“€ Suggestor πŸ“₯
    runs-on: 'ubuntu-latest'
    steps:
    - name: 🏁 Checkout
      uses: actions/checkout@v4
      with:
        sparse-checkout: |
          .github/workflows/*.y*ml
        sparse-checkout-cone-mode: false
    - name: Dispatch πŸ“€ Suggestor πŸ“₯
      id: dispatch-suggestor
      uses: Skenvy/dispatch-suggestor@v1
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}
    - name: List changed files
      run: echo "${{ steps.dispatch-suggestor.outputs.list-of-changed-files }}"
    - name: List dispatchable workflows
      run: echo "${{ steps.dispatch-suggestor.outputs.list-of-dispatchable-workflows }}"

About

Suggests relevant dispatchable workflows for a PR branch that would otherwise trigger the dispatchable workflows from pushes to the trunk.

Topics

Resources

License

Apache-2.0, Unknown licenses found

Licenses found

Apache-2.0
LICENSE
Unknown
LICENSE.typescript-action

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors