diff --git a/.github/actions/slack-message/action.yml b/.github/actions/slack-message/action.yml deleted file mode 100644 index d79ab6180..000000000 --- a/.github/actions/slack-message/action.yml +++ /dev/null @@ -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 '' ${{ github.run_id }})" >> $GITHUB_ENV - echo "commiturl=$(printf '' ${{ github.sha }})" >> $GITHUB_ENV - echo "refurl=$(printf '' ${{ 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 }}" - } - } - ] - } diff --git a/.github/actions/teams-message/action.yml b/.github/actions/teams-message/action.yml new file mode 100644 index 000000000..3bd657efc --- /dev/null +++ b/.github/actions/teams-message/action.yml @@ -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 }} diff --git a/.github/workflows/ci_test_cleanup.yml b/.github/workflows/ci_test_cleanup.yml index 944cfec43..0ea12cf10 100644 --- a/.github/workflows/ci_test_cleanup.yml +++ b/.github/workflows/ci_test_cleanup.yml @@ -34,12 +34,12 @@ jobs: m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }} m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }} - - name: Notify failure in slack + - name: Notify failure in teams if: failure() - uses: ./.github/actions/slack-message + uses: ./.github/actions/teams-message with: 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: environment: Testing @@ -71,9 +71,9 @@ jobs: m365-admin-user: ${{ secrets.M365_TENANT_ADMIN_USER }} m365-admin-password: ${{ secrets.M365_TENANT_ADMIN_PASSWORD }} - - name: Notify failure in slack + - name: Notify failure in teams if: failure() - uses: ./.github/actions/slack-message + uses: ./.github/actions/teams-message with: msg: "[FAILED] ${{ vars[matrix.site] }} CI Cleanup" - slack_url: ${{ secrets.SLACK_WEBHOOK_URL }} + teams_url: ${{ secrets.TEAMS_CORSO_CI_WEBHOOK_URL }} diff --git a/.github/workflows/longevity_test.yml b/.github/workflows/longevity_test.yml index 3de31c928..15fb539b8 100644 --- a/.github/workflows/longevity_test.yml +++ b/.github/workflows/longevity_test.yml @@ -389,9 +389,9 @@ jobs: if-no-files-found: error retention-days: 14 - - name: Notify failure in slack + - name: Notify failure in teams if: failure() - uses: ./.github/actions/slack-message + uses: ./.github/actions/teams-message with: msg: "[FAILED] Longevity Test" - slack_url: ${{ secrets.SLACK_WEBHOOK_URL }} + teams_url: ${{ secrets.TEAMS_CORSO_CI_WEBHOOK_URL }} diff --git a/.github/workflows/nightly_test.yml b/.github/workflows/nightly_test.yml index 9fbfa226e..42022ff0d 100644 --- a/.github/workflows/nightly_test.yml +++ b/.github/workflows/nightly_test.yml @@ -114,9 +114,9 @@ jobs: if-no-files-found: error retention-days: 14 - - name: Notify failure in slack + - name: Notify failure in teams if: failure() - uses: ./.github/actions/slack-message + uses: ./.github/actions/teams-message with: msg: "[FAILED] Nightly Checks" - slack_url: ${{ secrets.SLACK_WEBHOOK_URL }} + teams_url: ${{ secrets.TEAMS_CORSO_CI_WEBHOOK_URL }} diff --git a/.github/workflows/sanity-test.yaml b/.github/workflows/sanity-test.yaml index 87bc055f1..490070146 100644 --- a/.github/workflows/sanity-test.yaml +++ b/.github/workflows/sanity-test.yaml @@ -433,7 +433,7 @@ jobs: - name: Notify failure in slack if: failure() - uses: ./.github/actions/slack-message + uses: ./.github/actions/teams-message with: msg: "[FAILED] Sanity Tests" - slack_url: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file + teams_url: ${{ secrets.SLACK_WEBHOOK_URL }} \ No newline at end of file diff --git a/.github/workflows/testnotification.yml b/.github/workflows/testnotification.yml new file mode 100644 index 000000000..a1c672106 --- /dev/null +++ b/.github/workflows/testnotification.yml @@ -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 }}