Skip to content

Commit d471f6d

Browse files
authored
[ci] Add capability to rerun failed action on PR using /rerun comment (#14314)
<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This PR enables contributors to re-trigger failed jobs by using the /rerun comment in the PRs. The same was done in the [contrib side](open-telemetry/opentelemetry-collector-contrib#44957), and I think it is valuable to port it to the core side. <!--Describe the documentation added.--> #### Documentation Updated the CONTRIBUTING.md with this reference. <!--Please delete paragraphs that you did not use before submitting.--> --------- Signed-off-by: Paulo Dias <[email protected]>
1 parent 17646a7 commit d471f6d

File tree

3 files changed

+82
-4
lines changed

3 files changed

+82
-4
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Rerun Failed Workflows"
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
7+
permissions: read-all
8+
9+
jobs:
10+
rerun-failed:
11+
if: ${{ github.event.issue.pull_request && startsWith(github.event.comment.body, '/rerun') && github.repository_owner == 'open-telemetry' }}
12+
permissions:
13+
actions: write
14+
checks: read
15+
runs-on: ubuntu-24.04
16+
steps:
17+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
18+
- name: Run rerun-failed-workflows.sh
19+
run: ./.github/workflows/scripts/rerun-failed-workflows.sh
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
PR_NUMBER: ${{ github.event.issue.number }}
23+
COMMENT: ${{ github.event.comment.body }}
24+
SENDER: ${{ github.event.comment.user.login }}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright The OpenTelemetry Authors
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
7+
set -euo pipefail
8+
9+
if [[ -z "${PR_NUMBER:-}" || -z "${COMMENT:-}" || -z "${SENDER:-}" ]]; then
10+
echo "PR_NUMBER, COMMENT, or SENDER not set"
11+
exit 0
12+
fi
13+
14+
if [[ ${COMMENT:0:6} != "/rerun" ]]; then
15+
echo "Not a rerun command"
16+
exit 0
17+
fi
18+
19+
PR_DATA=$(gh pr view "${PR_NUMBER}" --json headRefOid,author)
20+
HEAD_SHA=$(echo "${PR_DATA}" | jq -r '.headRefOid')
21+
PR_AUTHOR=$(echo "${PR_DATA}" | jq -r '.author.login')
22+
23+
if [[ "${SENDER}" != "${PR_AUTHOR}" ]]; then
24+
echo "Only PR author can rerun workflows"
25+
exit 0
26+
fi
27+
28+
echo "Finding failed workflows for commit: ${HEAD_SHA}"
29+
30+
FAILED_RUNS=$(gh run list \
31+
--commit "${HEAD_SHA}" \
32+
--status failure \
33+
--json databaseId \
34+
--jq '.[].databaseId')
35+
36+
if [[ -z "${FAILED_RUNS}" ]]; then
37+
echo "No failed workflows found"
38+
exit 0
39+
else
40+
for RUN_ID in ${FAILED_RUNS}; do
41+
echo "Rerunning workflow: ${RUN_ID}"
42+
gh run rerun "${RUN_ID}" --failed
43+
done
44+
fi

CONTRIBUTING.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,16 @@ Example label comment:
127127
/label help-wanted -arm64
128128
```
129129

130+
### Rerunning Failed Workflows
131+
132+
PR authors can rerun failed GitHub Actions workflows by commenting `/rerun` on the pull request. This will automatically rerun all failed workflow runs for the PR's latest commit.
133+
134+
Example rerun comment:
135+
136+
```
137+
/rerun
138+
```
139+
130140
## How to contribute
131141

132142
### Before you start
@@ -144,7 +154,7 @@ Comment on the issue that you want to work on so we can assign it to you and
144154
clarify anything related to it.
145155

146156
If you would like to work on something that is not listed as an issue
147-
(e.g. a new feature or enhancement) please first read our [vision](docs/vision.md)
157+
(e.g. a new feature or enhancement) please first read our [vision](docs/vision.md)
148158
to make sure your proposal aligns with the goals of the
149159
Collector, then create an issue and describe your proposal. It is best to do this
150160
in advance so that maintainers can decide if the proposal is a good fit for
@@ -320,7 +330,7 @@ locally. Ensure that you execute these commands from the root of the repository:
320330

321331
The actual name of the binary will depend on your platform, adjust accordingly
322332
(e.g., `./bin/otelcorecol_darwin_arm64`).
323-
333+
324334
Replace `otel-config.yaml` with the appropriate configuration file as needed.
325335

326336
3. Verify that your changes are reflected in the Collector's behavior by testing
@@ -415,10 +425,10 @@ running the default common target for each module as well as additional repo-lev
415425
When a new OTLP version is published, the following steps are required to update this code base:
416426

417427
1. Edit the top-level Makefile's `OPENTELEMETRY_PROTO_VERSION` variable
418-
2. Run `make genproto`
428+
2. Run `make genproto`
419429
3. Inspect modifications to the generated code in `pdata/internal/data/protogen`
420430
4. When new fields are added in the protocol, make corresponding changes in `pdata/internal/cmd/pdatagen/internal`
421-
5. Run `make genpdata`
431+
5. Run `make genpdata`
422432
6. Inspect modifications to the generated code in `pdata/*`
423433
7. Run `make genproto-cleanup`, to remove temporary files
424434
8. Update the supported OTLP version in [README.md](./README.md).

0 commit comments

Comments
 (0)