|
56 | 56 | path: ${{ matrix.build_dir }}/test-results.xml |
57 | 57 | reporter: java-junit |
58 | 58 |
|
59 | | - notify-failure: |
60 | | - runs-on: ubuntu-22.04 |
61 | | - needs: [build] |
62 | | - if: failure() |
63 | | - steps: |
64 | | - - name: Notify Slack |
65 | | - continue-on-error: true |
66 | | - env: |
67 | | - GH_TOKEN: ${{ github.token }} |
68 | | - SLACK_WEBHOOK_URL: ${{ secrets.OMOQ_SLACK_WEBHOOK_URL }} |
69 | | - run: | |
70 | | - RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
71 | | - if [ "${{ github.event_name }}" = "pull_request" ]; then |
72 | | - # First-failure-only: skip if previous run on this branch also failed |
73 | | - PREV=$(gh api \ |
74 | | - "repos/${{ github.repository }}/actions/workflows/ci.yml/runs?branch=${{ github.head_ref }}&event=pull_request&per_page=2" \ |
75 | | - --jq '.workflow_runs[1].conclusion // "none"' 2>/dev/null) || PREV="none" |
76 | | - if [ "$PREV" = "failure" ]; then |
77 | | - echo "Previous run also failed — skipping" |
78 | | - exit 0 |
79 | | - fi |
80 | | - TEXT=":x: *${{ github.repository }}* \`${{ github.head_ref }}\` failed — <${{ github.event.pull_request.html_url }}|PR #${{ github.event.pull_request.number }}> · <${RUN_URL}|run> · <${{ github.event.pull_request.html_url }}/checks|tests>" |
81 | | - else |
82 | | - SHORT="${GITHUB_SHA:0:12}" |
83 | | - TEXT=":x: *${{ github.repository }}* \`${{ github.ref_name }}\` \`${SHORT}\` — build failed · <${RUN_URL}|run>" |
84 | | - fi |
85 | | - curl -s -X POST "$SLACK_WEBHOOK_URL" \ |
86 | | - -H "Content-Type: application/json" \ |
87 | | - --data "{\"text\": \"${TEXT}\"}" |
88 | | -
|
89 | | - - name: Notify email (main only) |
90 | | - if: github.event_name == 'push' |
91 | | - continue-on-error: true |
92 | | - env: |
93 | | - AWS_ACCESS_KEY_ID: ${{ secrets.OMOQ_AWS_ACCESS_KEY_ID }} |
94 | | - AWS_SECRET_ACCESS_KEY: ${{ secrets.OMOQ_AWS_SECRET_ACCESS_KEY }} |
95 | | - AWS_DEFAULT_REGION: us-east-1 |
96 | | - run: | |
97 | | - SHORT="${GITHUB_SHA:0:12}" |
98 | | - RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" |
99 | | - REPO_NAME="${{ github.event.repository.name }}" |
100 | | - SUBJECT="[${REPO_NAME}] build FAILED ${{ github.ref_name }} ${SHORT}" |
101 | | - BODY="${{ github.repository }} · ${{ github.ref_name }} · ${SHORT}\n${RUN_URL}" |
102 | | - aws ses send-email \ |
103 | | - --from "noreply@ci.openmoq.org" \ |
104 | | - --destination '{"ToAddresses":["github-notifications@openmoq.org"]}' \ |
105 | | - --message "{ |
106 | | - \"Subject\": {\"Data\": \"$SUBJECT\"}, |
107 | | - \"Body\": {\"Text\": {\"Data\": \"$BODY\"}} |
108 | | - }" |
0 commit comments