From dd176eb7a67769cc28139b4a7751ddc8d66f4c35 Mon Sep 17 00:00:00 2001 From: Ben Knutson Date: Wed, 18 Feb 2026 12:38:51 +0000 Subject: [PATCH] Refactor Github Action per b/485167538 --- .github/workflows/pr_notification.yml | 13 +++++++++---- .github/workflows/push_notification.yml | 17 ++++++++++++----- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pr_notification.yml b/.github/workflows/pr_notification.yml index fd532fb1..794ad682 100644 --- a/.github/workflows/pr_notification.yml +++ b/.github/workflows/pr_notification.yml @@ -11,13 +11,18 @@ jobs: - name: Pull Request Details run: | echo "Pull Request: ${{ github.event.pull_request.number }}" - echo "Author: ${{ github.event.pull_request.user.login }}" + echo "Author: ${GITHUB_EVENT_PULL_REQUEST_USER_LOGIN}" + env: + GITHUB_EVENT_PULL_REQUEST_USER_LOGIN: ${{ github.event.pull_request.user.login }} - name: Google Chat Notification shell: bash env: TITLE: ${{ github.event.pull_request.title }} LABELS: ${{ join(github.event.pull_request.labels.*.name, ', ') }} + GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }} + GITHUB_EVENT_PULL_REQUEST_USER_LOGIN: ${{ github.event.pull_request.user.login }} + GITHUB_EVENT_PULL_REQUEST_HTML_URL: ${{ github.event.pull_request.html_url }} run: | curl --location --request POST '${{ secrets.WEBHOOK_URL }}' \ --header 'Content-Type: application/json' \ @@ -34,7 +39,7 @@ jobs: { "keyValue": { "topLabel": "Repo", - "content": "${{ github.event.pull_request.head.repo.full_name }}" + "content": "${GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME}" } }, { @@ -46,7 +51,7 @@ jobs: { "keyValue": { "topLabel": "Creator", - "content": "${{ github.event.pull_request.user.login }}" + "content": "${GITHUB_EVENT_PULL_REQUEST_USER_LOGIN}" } }, { @@ -80,7 +85,7 @@ jobs: "text": "Open Pull Request", "onClick": { "openLink": { - "url": "${{ github.event.pull_request.html_url }}" + "url": "${GITHUB_EVENT_PULL_REQUEST_HTML_URL}" } } } diff --git a/.github/workflows/push_notification.yml b/.github/workflows/push_notification.yml index 1dc3ce1a..33e43c6e 100644 --- a/.github/workflows/push_notification.yml +++ b/.github/workflows/push_notification.yml @@ -14,8 +14,11 @@ jobs: - name: Main Branch Push run: | echo "Workflow initiated by event with name: ${{ github.event_name }}" - echo "Pushing commit to main: ${{ github.event.head_commit.id }}" - echo "Pushed by: ${{ github.event.pusher.name }}" + echo "Pushing commit to main: ${GITHUB_EVENT_HEAD_COMMIT_ID}" + echo "Pushed by: ${GITHUB_EVENT_PUSHER_NAME}" + env: + GITHUB_EVENT_HEAD_COMMIT_ID: ${{ github.event.head_commit.id }} + GITHUB_EVENT_PUSHER_NAME: ${{ github.event.pusher.name }} - name: Push Notification to Google Chat run: | @@ -34,13 +37,13 @@ jobs: { "keyValue": { "topLabel": "Repo", - "content": "${{ github.event.repository.full_name }}" + "content": "${GITHUB_EVENT_REPOSITORY_FULL_NAME}" } }, { "keyValue": { "topLabel": "Committed by", - "content": "${{ github.event.head_commit.author.username }}" + "content": "${GITHUB_EVENT_HEAD_COMMIT_AUTHOR_USERNAME}" } }, { @@ -50,7 +53,7 @@ jobs: "text": "Ref comparison", "onClick": { "openLink": { - "url": "${{ github.event.compare }}" + "url": "${GITHUB_EVENT_COMPARE}" } } } @@ -63,4 +66,8 @@ jobs: } ] }' + env: + GITHUB_EVENT_REPOSITORY_FULL_NAME: ${{ github.event.repository.full_name }} + GITHUB_EVENT_HEAD_COMMIT_AUTHOR_USERNAME: ${{ github.event.head_commit.author.username }} + GITHUB_EVENT_COMPARE: ${{ github.event.compare }}