From d8c69f46734cade3411602a2d53ce0ca3eeb2047 Mon Sep 17 00:00:00 2001 From: Ben Knutson Date: Wed, 18 Feb 2026 12:57:40 +0000 Subject: [PATCH] Refactor Github Action per b/485167538 --- .github/workflows/pr_notification.yml | 20 ++++++++++++++------ .github/workflows/push_notification.yml | 20 ++++++++++++++------ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pr_notification.yml b/.github/workflows/pr_notification.yml index 7c001037..07b73a3d 100644 --- a/.github/workflows/pr_notification.yml +++ b/.github/workflows/pr_notification.yml @@ -10,8 +10,11 @@ jobs: steps: - name: Pull Request Details run: | - echo "Pull Request: ${{ github.event.pull_request.title }}" - echo "Author: ${{ github.event.pull_request.user.login }}" + echo "Pull Request: ${GITHUB_EVENT_PULL_REQUEST_TITLE}" + echo "Author: ${GITHUB_EVENT_PULL_REQUEST_USER_LOGIN}" + env: + GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }} + GITHUB_EVENT_PULL_REQUEST_USER_LOGIN: ${{ github.event.pull_request.user.login }} - name: Google Chat Notification run: | @@ -30,19 +33,19 @@ jobs: { "keyValue": { "topLabel": "Repo", - "content": "${{ github.event.pull_request.head.repo.full_name }}" + "content": "${GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME}" } }, { "keyValue": { "topLabel": "Title", - "content": "${{ github.event.pull_request.title }}" + "content": "${GITHUB_EVENT_PULL_REQUEST_TITLE}" } }, { "keyValue": { "topLabel": "Creator", - "content": "${{ github.event.pull_request.user.login }}" + "content": "${GITHUB_EVENT_PULL_REQUEST_USER_LOGIN}" } }, { @@ -76,7 +79,7 @@ jobs: "text": "Open Pull Request", "onClick": { "openLink": { - "url": "${{ github.event.pull_request.html_url }}" + "url": "${GITHUB_EVENT_PULL_REQUEST_HTML_URL}" } } } @@ -89,3 +92,8 @@ jobs: } ] }' + env: + GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }} + GITHUB_EVENT_PULL_REQUEST_TITLE: ${{ github.event.pull_request.title }} + GITHUB_EVENT_PULL_REQUEST_USER_LOGIN: ${{ github.event.pull_request.user.login }} + GITHUB_EVENT_PULL_REQUEST_HTML_URL: ${{ github.event.pull_request.html_url }} diff --git a/.github/workflows/push_notification.yml b/.github/workflows/push_notification.yml index 5bede5bc..60315169 100644 --- a/.github/workflows/push_notification.yml +++ b/.github/workflows/push_notification.yml @@ -12,8 +12,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: | @@ -24,7 +27,7 @@ jobs: { "header": { "title": "Push to main branch", - "subtitle": "${{ github.event.head_commit.message }}" + "subtitle": "${GITHUB_EVENT_HEAD_COMMIT_MESSAGE}" }, "sections": [ { @@ -32,13 +35,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}" } }, { @@ -48,7 +51,7 @@ jobs: "text": "Ref comparison", "onClick": { "openLink": { - "url": "${{ github.event.compare }}" + "url": "${GITHUB_EVENT_COMPARE}" } } } @@ -61,4 +64,9 @@ jobs: } ] }' + env: + GITHUB_EVENT_HEAD_COMMIT_MESSAGE: ${{ github.event.head_commit.message }} + 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 }}