Skip to content

Commit 62c129a

Browse files
committed
refactor: replace CI failure email notification with GitHub issue creation
1 parent 4de6054 commit 62c129a

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed
Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI Failure Email
1+
name: CI Failure Issue
22

33
on:
44
workflow_run:
@@ -10,20 +10,35 @@ on:
1010
jobs:
1111
notify:
1212
if: contains(fromJSON('["failure","timed_out","action_required"]'), github.event.workflow_run.conclusion)
13+
permissions:
14+
issues: write
1315
runs-on: ubuntu-latest
1416
steps:
15-
- name: Send failure email
16-
uses: dawidd6/action-send-mail@v16
17-
with:
18-
connection_url: ${{ secrets.CI_FAILURE_MAIL_CONNECTION }}
19-
subject: "[CI failed] ${{ github.repository }} / ${{ github.event.workflow_run.name }}"
20-
to: sunnylqm@gmail.com
21-
from: "GitHub Actions <sunnylqm@gmail.com>"
22-
body: |
23-
Repository: ${{ github.repository }}
24-
Workflow: ${{ github.event.workflow_run.name }}
25-
Conclusion: ${{ github.event.workflow_run.conclusion }}
26-
Branch: ${{ github.event.workflow_run.head_branch }}
27-
Commit: ${{ github.event.workflow_run.head_sha }}
28-
Actor: ${{ github.event.workflow_run.actor.login }}
29-
Run: ${{ github.event.workflow_run.html_url }}
17+
- name: Create failure issue
18+
env:
19+
GH_TOKEN: ${{ github.token }}
20+
REPOSITORY: ${{ github.repository }}
21+
WORKFLOW_NAME: ${{ github.event.workflow_run.name }}
22+
CONCLUSION: ${{ github.event.workflow_run.conclusion }}
23+
HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}
24+
HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
25+
ACTOR: ${{ github.event.workflow_run.actor.login }}
26+
RUN_URL: ${{ github.event.workflow_run.html_url }}
27+
run: |
28+
body_file="$(mktemp)"
29+
cat > "$body_file" <<EOF
30+
@sunnylqm CI run failed.
31+
32+
Repository: $REPOSITORY
33+
Workflow: $WORKFLOW_NAME
34+
Conclusion: $CONCLUSION
35+
Branch: $HEAD_BRANCH
36+
Commit: $HEAD_SHA
37+
Actor: $ACTOR
38+
Run: $RUN_URL
39+
EOF
40+
41+
gh issue create \
42+
--repo "$REPOSITORY" \
43+
--title "[CI failed] $REPOSITORY / $WORKFLOW_NAME" \
44+
--body-file "$body_file"

0 commit comments

Comments
 (0)