https://github.com/int128/rerun-workflows-action
Rerun failed workflow runs by comment or label in GitHub Actions
https://github.com/int128/rerun-workflows-action
github-actions rerun
Last synced: 4 months ago
JSON representation
Rerun failed workflow runs by comment or label in GitHub Actions
- Host: GitHub
- URL: https://github.com/int128/rerun-workflows-action
- Owner: int128
- License: apache-2.0
- Created: 2024-11-01T07:48:36.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-08T06:01:15.000Z (over 1 year ago)
- Last Synced: 2025-03-08T07:17:59.551Z (over 1 year ago)
- Topics: github-actions, rerun
- Language: TypeScript
- Homepage:
- Size: 1.15 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rerun-workflows-action [](https://github.com/int128/rerun-workflows-action/actions/workflows/ts.yaml)
This action reruns the failed workflow runs.
## Motivation
GitHub does not provide an easy way to rerun the failed workflow runs.
We need to open each workflow run and click the **Re-run failed jobs** button.
## Getting started
### Trigger the rerun by a comment
The below example reruns the failed workflow runs when `/rerun` is commented on a pull request.
```yaml
# When `/rerun` is commented on a pull request, rerun the failed workflow runs.
name: rerun-by-comment
on:
issue_comment:
types:
- created
jobs:
rerun-workflows:
if: github.event.issue.pull_request && github.event.comment.body == '/rerun'
runs-on: ubuntu-latest
permissions:
actions: write # To rerun workflows
steps:
- uses: int128/rerun-workflows-action@v0
```
### Trigger the rerun by a label
The below example reruns the failed workflow runs when `/rerun` label is added to a pull request.
```yaml
# When `/rerun` label is added to a pull request, rerun the failed workflow runs.
name: rerun-by-label
on:
pull_request:
types:
- labeled
jobs:
rerun-workflows:
if: github.event.label.name == '/rerun'
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
actions: write # To rerun workflows
pull-requests: write # To remove label
steps:
- uses: int128/rerun-workflows-action@v0
- uses: int128/label-action@v1
with:
remove-labels: ${{ github.event.label.name }}
```
## Specification
This action finds the following statuses of workflow runs on the specified event and commit:
- `failure`
- `cancelled`
For example, there are the following workflow runs,
- :white_check_mark: `microservice1-test`
- :x: `microservice2-test`
- :white_check_mark: `microservice3-test`
- :x: `microservice4-test`
- :white_check_mark: `microservice5-test`
this action reruns `microservice2-test` and `microservice4-test`.
### Inputs
| Name | Default | Description |
| ------- | ------- | ------------------------------------ |
| `event` | - | Event name of workflow runs to rerun |
| `sha` | - | Commit SHA of workflow runs to rerun |
If `event` and `sha` are not specified, this action infers the event and commit as follows:
- When this action is run on `pull_request` event, it finds the workflow runs triggered by `pull_request` event.
- Otherwise, it does nothing.
### Outputs
| Name | Description |
| --------------------- | -------------------------------------------------------------------------- |
| `workflow-runs-count` | Number of workflow runs attempted to rerun |
| `rerun-success-count` | Number of workflow runs where the rerun request was accepted by GitHub API |
| `rerun-failure-count` | Number of workflow runs where the rerun request failed |
`rerun-success-count` means the rerun request was accepted by GitHub API.
It does not guarantee the rerun jobs will eventually succeed.
`rerun-failure-count` means the rerun request was rejected by GitHub API or failed to be sent.
GitHub API may reject the rerun request if the workflow run is too old.
If `rerun-failure-count` is greater than 0, this action shows a warning message but does not fail.