-
Notifications
You must be signed in to change notification settings - Fork 66.8k
Expand file tree
/
Copy pathaction.yml
More file actions
93 lines (86 loc) · 3.09 KB
/
action.yml
File metadata and controls
93 lines (86 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Create workflow failure issue
description: Create or update a GitHub issue in docs-engineering when a workflow fails, for automated diagnosis by an agentic workflow.
inputs:
token:
description: A token with issues write permission on the target repo
required: true
repo:
description: The repository to create the issue in
default: github/docs-engineering
required: false
runs:
using: composite
steps:
- name: Check for existing open issue
id: check-existing
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
ISSUE_REPO: ${{ inputs.repo }}
WORKFLOW_NAME: ${{ github.workflow }}
run: |
existing=$(gh issue list \
--repo "$ISSUE_REPO" \
--label "workflow-failure" \
--search "in:title [Workflow Failure] $WORKFLOW_NAME" \
--state open \
--json number \
--jq '.[0].number // empty' 2>/dev/null || true)
echo "existing_issue=$existing" >> "$GITHUB_OUTPUT"
- name: Comment on existing issue
if: steps.check-existing.outputs.existing_issue != ''
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
ISSUE_REPO: ${{ inputs.repo }}
ISSUE_NUMBER: ${{ steps.check-existing.outputs.existing_issue }}
WORKFLOW_NAME: ${{ github.workflow }}
SOURCE_REPO: ${{ github.repository }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
EVENT_NAME: ${{ github.event_name }}
GIT_REF: ${{ github.ref }}
run: |
body=$(cat <<EOF
### Repeat failure
**Workflow:** \`$WORKFLOW_NAME\`
**Repository:** \`$SOURCE_REPO\`
**Run:** $RUN_URL
**Event:** \`$EVENT_NAME\`
**Ref:** \`$GIT_REF\`
**Timestamp:** $(date -u +%Y-%m-%dT%H:%M:%SZ)
EOF
)
gh issue comment "$ISSUE_NUMBER" \
--repo "$ISSUE_REPO" \
--body "$body"
- name: Create workflow failure issue
if: steps.check-existing.outputs.existing_issue == ''
shell: bash
env:
GH_TOKEN: ${{ inputs.token }}
ISSUE_REPO: ${{ inputs.repo }}
WORKFLOW_NAME: ${{ github.workflow }}
SOURCE_REPO: ${{ github.repository }}
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: |
body=$(cat <<EOF
### Workflow failure
**Workflow:** \`$WORKFLOW_NAME\`
**Repository:** \`$SOURCE_REPO\`
**Run:** $RUN_URL
**Event:** \`$EVENT_NAME\`
**Ref:** \`$GIT_REF\`
**Triggered by:** \`$ACTOR\`
**Timestamp:** $(date -u +%Y-%m-%dT%H:%M:%SZ)
---
This issue was automatically created by the create-workflow-failure-issue action to enable automated diagnosis.
EOF
)
gh issue create \
--repo "$ISSUE_REPO" \
--label "workflow-failure" \
--title "[Workflow Failure] $WORKFLOW_NAME" \
--body "$body"