Skip to content

Commit 0c7f2d5

Browse files
[chore] File issue when update-otel workflow fails (#38032)
#### Description This PR records the output of the `update-otel` workflow into a file, and creates an issue with 'ci-cd' label containing the last 100 lines and a link to the full log if the main step fails. #### Link to tracking issue Resolves #37679 #### Testing I tested the code on my fork, with a dummy job that always fails ([workflow logs](https://github.com/jade-guiton-dd/opentelemetry-collector-contrib/actions/runs/13396711147), [resulting issue](jade-guiton-dd#8)).
1 parent de6f834 commit 0c7f2d5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.github/workflows/update-otel.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ jobs:
1919
repository: open-telemetry/opentelemetry-collector
2020
- name: Update to latest opentelemetry-collector release and create a PR
2121
run: |
22+
exec > >(tee log.out) 2>&1
2223
cd opentelemetry-collector-contrib
2324
git config user.name opentelemetrybot
2425
git config user.email [email protected]
@@ -30,3 +31,23 @@ jobs:
3031
gh pr create --base main --title "[chore] Update core dependencies" --body "This PR updates the opentelemetry-collector dependency to the latest release"
3132
env:
3233
GITHUB_TOKEN: ${{ secrets.OPENTELEMETRYBOT_GITHUB_TOKEN }}
34+
- name: File an issue if the workflow failed
35+
if: failure()
36+
run: |
37+
template=$(cat <<'END'
38+
[Link to job log](%s)
39+
40+
<details>
41+
<summary>Last 100 lines of log</summary>
42+
43+
```
44+
%s
45+
```
46+
</details>
47+
END
48+
)
49+
job_url="$(gh run view ${{ github.run_id }} -R ${{ github.repository }} --json jobs -q '.jobs[] | select(.name == "update-otel") | .url')"
50+
body="$(printf "$template" "$job_url" "$(tail -n100 log.out | tail -c63K)")"
51+
gh issue create -R ${{ github.repository }} -t 'update-otel workflow failed' -b "$body" -l 'ci-cd'
52+
env:
53+
GH_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)