Skip to content

Update pr-notification.yml #7

Update pr-notification.yml

Update pr-notification.yml #7

name: PR Notification to Google Chat
on:
pull_request:
types: [opened, synchronize, closed]
branches:
- develop
jobs:
notify:
runs-on: ubuntu-latest
if: github.repository == 'AOT-Technologies/forms-flow-ai-micro-front-ends'
steps:
- name: Determine PR Status
id: pr_status
run: |
if [[ "${{ github.event.action }}" == "opened" ]]; then
echo "status=🟢 Open" >> $GITHUB_ENV
elif [[ "${{ github.event.action }}" == "closed" && "${{ github.event.pull_request.merged }}" == "true" ]]; then
echo "status=🟣 Merged" >> $GITHUB_ENV
elif [[ "${{ github.event.action }}" == "closed" ]]; then
echo "status=🔴 Closed" >> $GITHUB_ENV
else
echo "status=🟢 Open" >> $GITHUB_ENV
fi
- name: Send notification to Google Chat
uses: fjogeleit/[email protected]
with:
url: ${{ secrets.WEBHOOK }}
method: POST
contentType: application/json
data: |
{
"cards": [
{
"header": {
"title": "Micro front-ends: Pull Request Opened by ${{ github.event.pull_request.user.login }}",
"subtitle": "Pull Request #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}",
"imageUrl": "${{ github.event.pull_request.user.avatar_url }}"
},
"sections": [
{
"widgets": [
{
"textParagraph": {
"text": "Repository: ${{ github.repository }}"
}
},
{
"textParagraph": {
"text": "Status: ${{ env.status }}"
}
},
{
"buttons": [
{
"textButton": {
"text": "View Pull Request",
"onClick": {
"openLink": {
"url": "${{ github.event.pull_request.html_url }}"
}
}
}
}
]
}
]
}
]
}
]
}