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.
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.
- uses: Shamrock-code/action-trigger-ci-empty-commit@v1
with:
github_token: ${{ secrets.GHACTION_PAT }}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.
| 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. |
- Removes the configured label from the pull request.
- Checks whether the PR head branch can be pushed (fork PRs require Allow edits from maintainers).
- 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. - If push is not possible: comments on the PR with instructions to enable maintainer edits or push the empty commit manually.
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.
MIT — see LICENSE.