Repository navigation
Carry nonce and claimsAsJSON through Device Policy flows (#637)
#147
This file contains hidden or 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: GSI Push Main Notification | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| jobs: | |
| notify-push-main: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Main Branch Push | |
| run: | | |
| echo "Workflow initiated by event with name: ${EVENT_NAME}" | |
| echo "Pushing commit to main: ${HEAD_COMMIT_ID}" | |
| echo "Pushed by: ${PUSHER_NAME}" | |
| env: | |
| EVENT_NAME: ${{ github.event_name }} | |
| HEAD_COMMIT_ID: ${{ github.event.head_commit.id }} | |
| PUSHER_NAME: ${{ github.event.pusher.name }} | |
| - name: Push Notification to Google Chat | |
| continue-on-error: true | |
| shell: bash | |
| env: | |
| WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }} | |
| COMMIT_MSG: ${{ github.event.head_commit.message }} | |
| AUTHOR: ${{ github.event.head_commit.author.username }} | |
| REPO: ${{ github.event.repository.full_name }} | |
| COMPARE_URL: ${{ github.event.compare }} | |
| run: | | |
| if [ -z "$WEBHOOK_URL" ]; then | |
| echo "WEBHOOK_URL secret is not set. Skipping notification." | |
| exit 0 | |
| fi | |
| PAYLOAD=$(jq -n \ | |
| --arg commit "$COMMIT_MSG" \ | |
| --arg author "$AUTHOR" \ | |
| --arg repo "$REPO" \ | |
| --arg compare "$COMPARE_URL" \ | |
| ' | |
| def guard(val): if (val == null or val == "") then "None" else val end; | |
| { | |
| cardsV2: [ | |
| { | |
| cardId: "pushNotificationCard", | |
| card: { | |
| header: { | |
| title: "Push to main branch", | |
| subtitle: guard($commit) | |
| }, | |
| sections: [ | |
| { | |
| widgets: [ | |
| { decoratedText: { topLabel: "Repo", text: guard($repo) } }, | |
| { decoratedText: { topLabel: "Committed by", text: guard($author) } }, | |
| { | |
| buttonList: { | |
| buttons: [ | |
| { | |
| text: "Ref comparison", | |
| onClick: { | |
| openLink: { | |
| url: $compare | |
| } | |
| } | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| } | |
| ] | |
| } | |
| } | |
| ] | |
| }') | |
| RESPONSE=$(curl --fail-with-body --location --request POST "$WEBHOOK_URL" \ | |
| --header 'Content-Type: application/json; charset=UTF-8' \ | |
| --data-raw "$PAYLOAD" 2>&1) || { | |
| echo "Failed to send Google Chat notification:" | |
| echo "$RESPONSE" | |
| exit 1 | |
| } | |