This repository has been archived by the owner on Oct 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
131 additions
and
72 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Manually Test Teams Action | ||
|
||
on: | ||
push: | ||
branches: [slack_message_to_teams] | ||
|
||
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 }} |