Skip to content
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

1 Commit
 
 
 
 
 
 

Repository files navigation

action-trigger-ci-empty-commit

Push an empty commit to a pull request branch to re-trigger CI. Intended for label-driven workflows: when a maintainer adds a label (default trigger-ci), the action removes the label and pushes an empty commit to the PR head branch.

If the PR comes from a fork and Allow edits from maintainers is disabled, the action posts a comment explaining how to trigger CI manually.

Setup

Create a repository secret named GHACTION_PAT before using this action.

The PAT must be able to:

  • remove labels on pull requests
  • push commits to PR head branches (including fork branches when Allow edits from maintainers is enabled)

In GitHub: Settings → Secrets and variables → Actions → New repository secret → name GHACTION_PAT, value your PAT.

Usage

- uses: Shamrock-code/action-trigger-ci-empty-commit@v1
  with:
    github_token: ${{ secrets.GHACTION_PAT }}

Example workflow

This action must run in a workflow triggered by a pull request event so github.event.pull_request is available. The Shamrock setup uses pull_request_target with a label filter:

name: trigger-ci-empty-commit

on:
  pull_request_target:
    types: [labeled]

concurrency:
  group: trigger-ci-${{ github.event.pull_request.number }}
  cancel-in-progress: false

jobs:
  trigger_ci:
    name: Trigger CI with empty commit
    if: ${{ github.event.label.name == 'trigger-ci' }}
    runs-on: ubuntu-latest

    permissions:
      contents: write
      issues: write

    steps:
      - uses: Shamrock-code/action-trigger-ci-empty-commit@v1
        with:
          github_token: ${{ secrets.GHACTION_PAT }}

To use a different label, pass the label input and match it in the job if condition.

Inputs

Input Required Default Description
github_token yes Pass ${{ secrets.GHACTION_PAT }}. Used to remove the label, check out the PR branch, push the empty commit, and post comments when push is not possible.
label no trigger-ci Label removed after the workflow runs; also referenced in the fork PR comment.

Behavior

  1. Removes the configured label from the pull request.
  2. Checks whether the PR head branch can be pushed (fork PRs require Allow edits from maintainers).
  3. If push is possible: checks out the PR head branch, creates an empty commit with message [gh-action] trigger CI with empty commit, and pushes it.
  4. If push is not possible: comments on the PR with instructions to enable maintainer edits or push the empty commit manually.

Fork pull requests

For PRs from forks, the contributor must enable Allow edits from maintainers. Without that, the action cannot push to the fork branch and will only leave an explanatory comment.

License

MIT — see LICENSE.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors