va de nuez #1 #10
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
name: Google Chat Notification | |
on: | |
push: | |
branches: | |
- '*' | |
jobs: | |
send_notification: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Extract commit information | |
run: | | |
COMMIT_MESSAGE=$(git log -1 --pretty=%B) | |
if [[ $COMMIT_MESSAGE =~ \#([0-9]+) ]]; then | |
ISSUE_NUMBER="${BASH_REMATCH[1]}" | |
fi | |
AUTHOR=$(git log -1 --pretty=format:'%an') | |
BRANCH=$(echo ${{ github.ref }} | awk -F'/' '{print $NF}') | |
if [ -z "$ISSUE_NUMBER" ]; then | |
MESSAGE="<b><font color=\"#4285F4\">$AUTHOR</font></b> subió cambios en la rama <b>$BRANCH</b>" | |
else | |
MESSAGE="<b><font color=\"#4285F4\">$AUTHOR</font></b> subió cambios en el issue <b>#${ISSUE_NUMBER}</b> en la rama <b>$BRANCH</b>" | |
fi | |
curl -X POST -H 'Content-Type: application/json' -d '{ | |
"cards": [ | |
{ | |
"sections": [ | |
{ | |
"widgets": [ | |
{ | |
"textParagraph": { | |
"text": "'"$MESSAGE"'" | |
} | |
} | |
] | |
} | |
] | |
} | |
] | |
}' "$CHAT_WEBHOOK_URL" | |
env: | |
CHAT_WEBHOOK_URL: ${{ secrets.CHAT_WEBHOOK_URL }} |