Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .github/actions/create-workflow-failure-issue/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ inputs:
default: github/docs-engineering
required: false

outputs:
issue_url:
description: URL of the created or updated workflow-failure issue (empty if creation failed).
value: ${{ steps.create-new.outputs.issue_url || steps.comment-existing.outputs.issue_url }}

runs:
using: composite
steps:
Expand All @@ -31,6 +36,7 @@ runs:
echo "existing_issue=$existing" >> "$GITHUB_OUTPUT"

- name: Comment on existing issue
id: comment-existing
if: steps.check-existing.outputs.existing_issue != ''
shell: bash
env:
Expand All @@ -57,8 +63,10 @@ runs:
gh issue comment "$ISSUE_NUMBER" \
--repo "$ISSUE_REPO" \
--body "$body"
echo "issue_url=$GITHUB_SERVER_URL/$ISSUE_REPO/issues/$ISSUE_NUMBER" >> "$GITHUB_OUTPUT"

- name: Create workflow failure issue
id: create-new
if: steps.check-existing.outputs.existing_issue == ''
shell: bash
env:
Expand Down Expand Up @@ -86,9 +94,10 @@ runs:
This issue was automatically created by the create-workflow-failure-issue action to enable automated diagnosis.
EOF
)
gh issue create \
url=$(gh issue create \
--repo "$ISSUE_REPO" \
--label "workflow-failure" \
--label "workflow-generated" \
--title "[Workflow Failure] $WORKFLOW_NAME" \
--body "$body"
--body "$body")
echo "issue_url=$url" >> "$GITHUB_OUTPUT"
54 changes: 51 additions & 3 deletions .github/actions/slack-alert/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,61 @@ inputs:
default: CG5MJHMB2 # docs-alerts
required: false
message:
description: The message to send to Slack
default: The last '${{ github.workflow }}' run failed. See ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
description: >-
Optional message override. When set, it is sent verbatim. When empty (the
default), a standard multi-line failure message is built from the run
context, plus a link to the failure issue if issue_url is provided.
default: ''
required: false
issue_url:
description: >-
Optional link to the tracking failure issue (e.g. the output of the
create-workflow-failure-issue action). Appended to the default message.
Ignored when a custom message is provided.
default: ''
required: false

runs:
using: composite
steps:
# Build the Slack text here so the default message can be multi-line (real
# newlines) and conditionally include the issue link. A caller-supplied
# message is passed through verbatim for backward compatibility.
- name: Build Slack message
id: build
shell: bash
env:
MESSAGE: ${{ inputs.message }}
ISSUE_URL: ${{ inputs.issue_url }}
SOURCE_REPO: ${{ github.repository }}
WORKFLOW_NAME: ${{ github.workflow }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
EVENT_NAME: ${{ github.event_name }}
GIT_REF: ${{ github.ref }}
ACTOR: ${{ github.actor }}
run: |
# Escape Slack mrkdwn control chars in interpolated context fields so a
# crafted branch/ref (e.g. containing <!channel>) can't inject mentions.
esc() { printf '%s' "$1" | sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g'; }
# Unique heredoc delimiter so a custom message can't collide with it.
delim="SLACK_EOF_${RANDOM}${RANDOM}"
{
printf 'text<<%s\n' "$delim"
if [ -n "$MESSAGE" ]; then
printf '%s\n' "$MESSAGE"
else
printf ':actions: *Workflow failure* in %s: %s\n' "$(esc "$SOURCE_REPO")" "$(esc "$WORKFLOW_NAME")"
printf 'on %s · %s · by %s\n' "$(esc "$EVENT_NAME")" "$(esc "$GIT_REF")" "$(esc "$ACTOR")"
printf 'Run: %s\n' "$RUN_URL"
if [ -n "$ISSUE_URL" ]; then
printf 'Issue: %s\n' "$ISSUE_URL"
else
printf ':warning: No issue created\n'
fi
fi
printf '%s\n' "$delim"
} >> "$GITHUB_OUTPUT"
- name: Send Slack notification if workflow fails
uses: slackapi/slack-github-action@45a88b9581bfab2566dc881e2cd66d334e621e2c # v3.0.3
with:
Expand All @@ -25,4 +73,4 @@ runs:
errors: true
payload: |
channel: ${{ toJSON(inputs.slack_channel_id) }}
text: ${{ toJSON(inputs.message) }}
text: ${{ toJSON(steps.build.outputs.text) }}
10 changes: 6 additions & 4 deletions .github/workflows/benchmark-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,14 @@ jobs:
echo "Done creating issue"
fi

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
10 changes: 6 additions & 4 deletions .github/workflows/changelog-agent.yml
Original file line number Diff line number Diff line change
Expand Up @@ -736,12 +736,14 @@ jobs:
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
10 changes: 6 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ jobs:
- uses: github/codeql-action/analyze@e296a935590eb16afc0c0108289f68c87e2a89a5 # v4.30.7
continue-on-error: true

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'pull_request' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'pull_request' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
10 changes: 6 additions & 4 deletions .github/workflows/content-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,14 @@ jobs:
--label "workflow-generated,content-pipeline-update,ready-for-doc-review,skip FR board"
fi

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
11 changes: 9 additions & 2 deletions .github/workflows/copy-api-issue-to-internal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,16 @@ jobs:
OLD_ISSUE: ${{ github.event.issue.html_url }}

- name: Check out repo
if: ${{ failure() && github.event_name != 'workflow_dispatch' && github.repository == 'github/docs-internal' }}
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' && github.repository == 'github/docs-internal' }}
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
10 changes: 6 additions & 4 deletions .github/workflows/create-changelog-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,14 @@ jobs:
core.info(`Failed to assign PR to @${context.payload.comment.user.login}: ${err.message}`);
}

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
10 changes: 6 additions & 4 deletions .github/workflows/delete-orphan-translation-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,14 @@ jobs:
fi
fi

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
10 changes: 6 additions & 4 deletions .github/workflows/docs-review-collect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ jobs:
REVIEWER: 'docs-reviewers'
FEATURE: 'Audit log event descriptions'

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
10 changes: 6 additions & 4 deletions .github/workflows/enterprise-dates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,14 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
number: ${{ steps.create-pull-request.outputs.pull-request-number }}

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
10 changes: 6 additions & 4 deletions .github/workflows/enterprise-release-issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
10 changes: 6 additions & 4 deletions .github/workflows/index-autocomplete-search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ jobs:
ELASTICSEARCH_URL: ${{ github.event_name == 'pull_request' && 'http://localhost:9200' || secrets.ELASTICSEARCH_URL }}
run: npm run index-ai-search-autocomplete -- docs-internal-data

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name == 'schedule' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name == 'schedule' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
30 changes: 18 additions & 12 deletions .github/workflows/index-general-search.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,16 @@ jobs:
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}

updateElasticsearchIndexes:
needs: figureOutMatrix
Expand Down Expand Up @@ -240,15 +242,17 @@ jobs:
path: /tmp/records/failures-summary.json
retention-days: 1

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() && github.event_name != 'workflow_dispatch' }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}

notifyScrapingFailures:
name: Notify scraping failures
Expand Down Expand Up @@ -383,12 +387,14 @@ jobs:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
message: ${{ fromJSON(steps.aggregate.outputs.result || '{"message":""}').message }}

- uses: ./.github/actions/slack-alert
- uses: ./.github/actions/create-workflow-failure-issue
id: create-failure-issue
if: ${{ failure() }}
with:
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
token: ${{ secrets.DOCS_BOT_PAT_BASE }}

- uses: ./.github/actions/create-workflow-failure-issue
- uses: ./.github/actions/slack-alert
if: ${{ failure() }}
with:
token: ${{ secrets.DOCS_BOT_PAT_BASE }}
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
issue_url: ${{ steps.create-failure-issue.outputs.issue_url }}
Loading
Loading