Skip to content
45 changes: 45 additions & 0 deletions .github/actions/report-failure/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: 'Report failure'
description: >-
Track failures of a scheduled workflow in a single open issue: open it on the
first failure and comment on it for every subsequent one until someone closes
it. Run this as the last step with "if: failure()".
Requires the calling job to have "permissions: issues: write".

inputs:
label:
description: Label that identifies the failure-tracking issue for this workflow.
required: true
assignees:
description: Comma-separated GitHub users to assign to a newly opened issue.
required: true

runs:
using: 'composite'
steps:
- name: Open or update failure issue
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
LABEL: ${{ inputs.label }}
ASSIGNEES: ${{ inputs.assignees }}
WORKFLOW: ${{ github.workflow }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |-
set -euo pipefail
gh label create "$LABEL" --force \
--color B60205 \
--description "The $WORKFLOW workflow is failing"
issue="$(gh issue list --label "$LABEL" --state open --json number --jq '.[0].number // empty')"
if [ -n "$issue" ]; then
gh issue comment "$issue" --body "Failed again: $RUN_URL"
else
# Assign individuals: a team mention posted by github-actions does not
# notify the team's members.
gh issue create --label "$LABEL" \
--assignee "$ASSIGNEES" \
--title "$WORKFLOW workflow is failing" \
--body "@databricks/eng-deco-cli the scheduled \`$WORKFLOW\` workflow failed.

$RUN_URL"
fi
11 changes: 11 additions & 0 deletions .github/workflows/bump-go-toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ permissions:
contents: write
pull-requests: write

# Required to open or comment on the failure-tracking issue.
issues: write

jobs:
bump-go-toolchain:
runs-on:
Expand Down Expand Up @@ -125,3 +128,11 @@ jobs:
-c user.email='41898282+github-actions[bot]@users.noreply.github.com' \
commit -m "Add changelog fragment"
git push origin "HEAD:$BRANCH"

# A failed scheduled run is otherwise only visible in the Actions tab.
- name: Report failure
if: failure()
uses: ./.github/actions/report-failure
with:
label: bump-go-toolchain-failure
assignees: simonfaltum,andrewnester,anton-107,denik,janniklasrose,pietern,shreyas-goenka
11 changes: 11 additions & 0 deletions .github/workflows/bump-vuln-deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ permissions:
contents: write
pull-requests: write

# Required to open or comment on the failure-tracking issue.
issues: write

# Required by setup-jfrog (GOPROXY exchange).
id-token: write

Expand Down Expand Up @@ -120,3 +123,11 @@ jobs:
-c user.email='41898282+github-actions[bot]@users.noreply.github.com' \
commit -m "Add changelog fragment"
git push origin "HEAD:$BRANCH"

# A failed scheduled run is otherwise only visible in the Actions tab.
- name: Report failure
if: failure()
uses: ./.github/actions/report-failure
with:
label: bump-vuln-deps-failure
assignees: simonfaltum,andrewnester,anton-107,denik,janniklasrose,pietern,shreyas-goenka
Loading