|
1 | | -name: CI Failure Email |
| 1 | +name: CI Failure Issue |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | workflow_run: |
|
10 | 10 | jobs: |
11 | 11 | notify: |
12 | 12 | if: contains(fromJSON('["failure","timed_out","action_required"]'), github.event.workflow_run.conclusion) |
| 13 | + permissions: |
| 14 | + issues: write |
13 | 15 | runs-on: ubuntu-latest |
14 | 16 | 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