github-actions: Add gchat notification (#31832)

Signed-off-by: Miguel Ruiz <miguel.ruiz@broadcom.com>
This commit is contained in:
Miguel Ruiz
2025-02-10 12:07:16 +01:00
committed by GitHub
parent 1d987751f6
commit b8a3eb8c47
5 changed files with 37 additions and 44 deletions

View File

@@ -169,3 +169,15 @@ jobs:
echo "Could not update the index after $max_attempts attempts"
exit 1
fi
notify:
name: Send notification
needs:
- vib-publish
- update-deprecated-index
if: ${{ always() && (needs.vib-publish.result == 'failure' || needs.update-deprecated-index.result == 'failure') }}
uses: bitnami/support/.github/workflows/gchat-notification.yml@main
with:
workflow: ${{ github.workflow }}
job-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
secrets:
webhook-url: ${{ secrets.GCHAT_CONTENT_ALERTS_WEBHOOK_URL }}

View File

@@ -1,42 +0,0 @@
# Copyright Broadcom, Inc. All Rights Reserved.
# SPDX-License-Identifier: APACHE-2.0
name: 'GChat Notification'
on:
workflow_call:
inputs:
workflow:
type: string
required: true
job-url:
type: string
required: true
repository:
type: string
secrets:
GCHAT_WEBHOOK_URL:
required: true
# Remove all permissions by default
permissions: {}
jobs:
notification:
name: Google Chat Notification
runs-on: ubuntu-latest
steps:
- name: Notify
env:
JOB_URL: ${{ inputs.job-url }}
GH_WORKFLOW: ${{ inputs.workflow }}
GH_REPOSITORY: ${{ inputs.repository != '' && inputs.repository || github.repository }}
GCHAT_WEBHOOK_URL: ${{ secrets.GCHAT_WEBHOOK_URL }}
run: |
tmp_file=$(mktemp)
cat >"${tmp_file}"<<EOF
⚠️ [${GH_REPOSITORY}] Failure detected on '${GH_WORKFLOW}' workflow ⚠️
📑 See details <${JOB_URL}|here>.
EOF
# Use curl to send the JSON to Google.
escapedText=$(sed -e 's/\n/\\n/g' -e 's/"/\\"/g' -e "s/'/\\'/g" "${tmp_file}")
json="{\"text\": \"$escapedText\"}"
curl -o /tmp/out -s --fail -X POST -H 'Content-Type: application/json' -d "$json" "${GCHAT_WEBHOOK_URL}"

View File

@@ -113,8 +113,9 @@ jobs:
name: Send notification
needs: [validation-check, integrity-check]
if: ${{ always() && (needs.validation-check.outputs.result != 'ok' || needs.integrity-check.outputs.result != 'ok') }}
uses: bitnami/charts/.github/workflows/gchat-notification.yml@main
uses: bitnami/support/.github/workflows/gchat-notification.yml@main
with:
workflow: ${{ github.workflow }}
job-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
secrets: inherit
secrets:
webhook-url: ${{ secrets.GCHAT_WEBHOOK_URL }}

View File

@@ -115,3 +115,14 @@ jobs:
# Push changes
git add bitnami/index.yaml && git commit --signoff --amend --no-edit
git push origin index --force-with-lease=index:${current_commit_id}
notify:
name: Send notification
needs:
- update-index
if: ${{ always() && (needs.update-index.result == 'failure') }}
uses: bitnami/support/.github/workflows/gchat-notification.yml@main
with:
workflow: ${{ github.workflow }}
job-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
secrets:
webhook-url: ${{ secrets.GCHAT_CONTENT_ALERTS_WEBHOOK_URL }}

View File

@@ -86,3 +86,14 @@ jobs:
git tag ${CHART}/${chart_version}
git push --tags
fi
notify:
name: Send notification
needs:
- push-tag
if: ${{ always() && (needs.push-tag.result == 'failure') }}
uses: bitnami/support/.github/workflows/gchat-notification.yml@main
with:
workflow: ${{ github.workflow }}
job-url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
secrets:
webhook-url: ${{ secrets.GCHAT_CONTENT_ALERTS_WEBHOOK_URL }}