Teams notification action (#4577)
Allows us to send CI notifications to Teams. Logic mirrors what we have in the slack-message action. We will remove the slack action once this is verified. --- #### Does this PR need a docs update or release note? - [ ] ✅ Yes, it's included - [ ] 🕐 Yes, but in a later PR - [x] ⛔ No #### Type of change <!--- Please check the type of change your PR introduces: ---> - [ ] 🌻 Feature - [ ] 🐛 Bugfix - [ ] 🗺️ Documentation - [ ] 🤖 Supportability/Tests - [x] 💻 CI/Deployment - [ ] 🧹 Tech Debt/Cleanup #### Issue(s) <!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. --> * #<issue> #### Test Plan <!-- How will this be tested prior to merging.--> - [ ] 💪 Manual - [ ] ⚡ Unit test - [ ] 💚 E2E
This commit is contained in:
parent
73b4ba3e0c
commit
54364ed6f0
58
.github/actions/slack-message/action.yml
vendored
58
.github/actions/slack-message/action.yml
vendored
@ -1,58 +0,0 @@
|
|||||||
name: Send a message to slack
|
|
||||||
|
|
||||||
inputs:
|
|
||||||
msg:
|
|
||||||
description: The slack message text
|
|
||||||
slack_url:
|
|
||||||
description: passthrough for secrets.SLACK_WEBHOOK_URL
|
|
||||||
|
|
||||||
runs:
|
|
||||||
using: composite
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
|
|
||||||
- name: set github ref
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "github_reference=${{ github.ref }}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: trim github ref
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "trimmed_ref=${github_reference#refs/}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: build urls
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "logurl=$(printf '<https://github.com/alcionai/corso/actions/runs/%s|[Action]>' ${{ github.run_id }})" >> $GITHUB_ENV
|
|
||||||
echo "commiturl=$(printf '<https://github.com/alcionai/corso/commit/%s|[Commit]>' ${{ github.sha }})" >> $GITHUB_ENV
|
|
||||||
echo "refurl=$(printf '<https://github.com/alcionai/corso/%s|[Ref]>' ${{ env.trimmed_ref }})" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: use url or blank val
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "STEP=${{ env.trimmed_ref || '' }}" >> $GITHUB_ENV
|
|
||||||
echo "JOB=${{ github.job || '' }}" >> $GITHUB_ENV
|
|
||||||
echo "LOGS=${{ github.run_id && env.logurl || '-' }}" >> $GITHUB_ENV
|
|
||||||
echo "COMMIT=${{ github.sha && env.commiturl || '-' }}" >> $GITHUB_ENV
|
|
||||||
echo "REF=${{ env.trimmed_ref && env.refurl || '-' }}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- id: slack-message
|
|
||||||
uses: slackapi/slack-github-action@v1.24.0
|
|
||||||
env:
|
|
||||||
SLACK_WEBHOOK_URL: ${{ inputs.slack_url }}
|
|
||||||
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
|
|
||||||
with:
|
|
||||||
payload: |
|
|
||||||
{
|
|
||||||
"text": "${{ inputs.msg }} :: ${{ env.LOGS }} ${{ env.COMMIT }} ${{ env.REF }}",
|
|
||||||
"blocks": [
|
|
||||||
{
|
|
||||||
"type": "section",
|
|
||||||
"text": {
|
|
||||||
"type": "mrkdwn",
|
|
||||||
"text": "${{ inputs.msg }}\n${{ env.JOB }} :: ${{ env.STEP }}\n${{ env.LOGS }} ${{ env.COMMIT }} ${{ env.REF }}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
91
.github/actions/teams-message/action.yml
vendored
Normal file
91
.github/actions/teams-message/action.yml
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
name: Send a message to Teams
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
msg:
|
||||||
|
description: The teams message text
|
||||||
|
teams_url:
|
||||||
|
description: passthrough for secrets.TEAMS_CORSO_CI_WEBHOOK_URL
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: set github ref
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "github_reference=${{ github.ref }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: trim github ref
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "trimmed_ref=${github_reference#refs/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: build urls
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "logurl=$(printf 'https://github.com/alcionai/corso/actions/runs/%s' ${{ github.run_id }})" >> $GITHUB_ENV
|
||||||
|
echo "commiturl=$(printf 'https://github.com/alcionai/corso/commit/%s' ${{ github.sha }})" >> $GITHUB_ENV
|
||||||
|
echo "refurl=$(printf 'https://github.com/alcionai/corso/%s' ${{ env.trimmed_ref }})" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: use url or blank val
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "STEP=${{ env.trimmed_ref || '' }}" >> $GITHUB_ENV
|
||||||
|
echo "JOB=${{ github.job || '' }}" >> $GITHUB_ENV
|
||||||
|
echo "LOGS=${{ github.run_id && env.logurl || '-' }}" >> $GITHUB_ENV
|
||||||
|
echo "COMMIT=${{ github.sha && env.commiturl || '-' }}" >> $GITHUB_ENV
|
||||||
|
echo "REF=${{ env.trimmed_ref && env.refurl || '-' }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Send JSON payload to Teams Webhook
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
curl -X POST \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d '{
|
||||||
|
"type":"message",
|
||||||
|
"attachments":[
|
||||||
|
{
|
||||||
|
"contentType":"application/vnd.microsoft.card.adaptive",
|
||||||
|
"contentUrl":null,
|
||||||
|
"content":{
|
||||||
|
"$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
|
||||||
|
"type":"AdaptiveCard",
|
||||||
|
"body": [
|
||||||
|
{
|
||||||
|
"type": "TextBlock",
|
||||||
|
"size": "Medium",
|
||||||
|
"weight": "Bolder",
|
||||||
|
"text": "${{ inputs.msg }}",
|
||||||
|
"color": "Attention"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "TextBlock",
|
||||||
|
"text": "${{ env.JOB }} :: ${{ env.STEP }}",
|
||||||
|
"wrap": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actions": [
|
||||||
|
{
|
||||||
|
"type": "Action.OpenUrl",
|
||||||
|
"title": "Action",
|
||||||
|
"url": "${{ env.LOGS }}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Action.OpenUrl",
|
||||||
|
"title": "Commit",
|
||||||
|
"url": "${{ env.COMMIT }}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "Action.OpenUrl",
|
||||||
|
"title": "Ref",
|
||||||
|
"url": "${{ env.REF }}"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
|
||||||
|
"version": "1.5"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}' \
|
||||||
|
${{ inputs.teams_url }}
|
||||||
12
.github/workflows/ci_test_cleanup.yml
vendored
12
.github/workflows/ci_test_cleanup.yml
vendored
@ -34,12 +34,12 @@ jobs:
|
|||||||
m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }}
|
m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }}
|
||||||
m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }}
|
m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }}
|
||||||
|
|
||||||
- name: Notify failure in slack
|
- name: Notify failure in teams
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: ./.github/actions/slack-message
|
uses: ./.github/actions/teams-message
|
||||||
with:
|
with:
|
||||||
msg: "[FAILED] ${{ vars[matrix.user] }} CI Cleanup"
|
msg: "[FAILED] ${{ vars[matrix.user] }} CI Cleanup"
|
||||||
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
teams_url: ${{ secrets.TEAMS_CORSO_CI_WEBHOOK_URL }}
|
||||||
|
|
||||||
Test-Site-Data-Cleanup:
|
Test-Site-Data-Cleanup:
|
||||||
environment: Testing
|
environment: Testing
|
||||||
@ -71,9 +71,9 @@ jobs:
|
|||||||
m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }}
|
m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }}
|
||||||
m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }}
|
m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }}
|
||||||
|
|
||||||
- name: Notify failure in slack
|
- name: Notify failure in teams
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: ./.github/actions/slack-message
|
uses: ./.github/actions/teams-message
|
||||||
with:
|
with:
|
||||||
msg: "[FAILED] ${{ vars[matrix.site] }} CI Cleanup"
|
msg: "[FAILED] ${{ vars[matrix.site] }} CI Cleanup"
|
||||||
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
teams_url: ${{ secrets.TEAMS_CORSO_CI_WEBHOOK_URL }}
|
||||||
|
|||||||
6
.github/workflows/longevity_test.yml
vendored
6
.github/workflows/longevity_test.yml
vendored
@ -389,9 +389,9 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
- name: Notify failure in slack
|
- name: Notify failure in teams
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: ./.github/actions/slack-message
|
uses: ./.github/actions/teams-message
|
||||||
with:
|
with:
|
||||||
msg: "[FAILED] Longevity Test"
|
msg: "[FAILED] Longevity Test"
|
||||||
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
teams_url: ${{ secrets.TEAMS_CORSO_CI_WEBHOOK_URL }}
|
||||||
|
|||||||
6
.github/workflows/nightly_test.yml
vendored
6
.github/workflows/nightly_test.yml
vendored
@ -114,9 +114,9 @@ jobs:
|
|||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
- name: Notify failure in slack
|
- name: Notify failure in teams
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: ./.github/actions/slack-message
|
uses: ./.github/actions/teams-message
|
||||||
with:
|
with:
|
||||||
msg: "[FAILED] Nightly Checks"
|
msg: "[FAILED] Nightly Checks"
|
||||||
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
teams_url: ${{ secrets.TEAMS_CORSO_CI_WEBHOOK_URL }}
|
||||||
|
|||||||
4
.github/workflows/sanity-test.yaml
vendored
4
.github/workflows/sanity-test.yaml
vendored
@ -433,7 +433,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Notify failure in slack
|
- name: Notify failure in slack
|
||||||
if: failure()
|
if: failure()
|
||||||
uses: ./.github/actions/slack-message
|
uses: ./.github/actions/teams-message
|
||||||
with:
|
with:
|
||||||
msg: "[FAILED] Sanity Tests"
|
msg: "[FAILED] Sanity Tests"
|
||||||
slack_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
teams_url: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||||
23
.github/workflows/testnotification.yml
vendored
Normal file
23
.github/workflows/testnotification.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
name: Manually Test Teams Action
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
msg:
|
||||||
|
description: 'Message to send:'
|
||||||
|
required: true
|
||||||
|
default: 'This is a test message'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
notify:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Send notification
|
||||||
|
uses: ./.github/actions/teams-message
|
||||||
|
with:
|
||||||
|
msg: ${{ github.event.inputs.msg }}
|
||||||
|
teams_url: ${{ secrets.TEAMS_CORSO_CI_WEBHOOK_URL }}
|
||||||
Loading…
x
Reference in New Issue
Block a user