Skip to content

Commit 0f580b9

Browse files
benknutson-googlew-goog
authored andcommitted
Refactor Github Action per b/485167538
1 parent da72bf9 commit 0f580b9

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

.github/workflows/pr_notification.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ jobs:
1111
- name: Pull Request Details
1212
run: |
1313
echo "Pull Request: ${{ github.event.pull_request.number }}"
14-
echo "Author: ${{ github.event.pull_request.user.login }}"
14+
echo "Author: ${GITHUB_EVENT_PULL_REQUEST_USER_LOGIN}"
15+
env:
16+
GITHUB_EVENT_PULL_REQUEST_USER_LOGIN: ${{ github.event.pull_request.user.login }}
1517

1618
- name: Google Chat Notification
1719
shell: bash
1820
env:
1921
TITLE: ${{ github.event.pull_request.title }}
2022
LABELS: ${{ join(github.event.pull_request.labels.*.name, ', ') }}
23+
GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME: ${{ github.event.pull_request.head.repo.full_name }}
24+
GITHUB_EVENT_PULL_REQUEST_USER_LOGIN: ${{ github.event.pull_request.user.login }}
25+
GITHUB_EVENT_PULL_REQUEST_HTML_URL: ${{ github.event.pull_request.html_url }}
2126
run: |
2227
curl --location --request POST '${{ secrets.WEBHOOK_URL }}' \
2328
--header 'Content-Type: application/json' \
@@ -34,7 +39,7 @@ jobs:
3439
{
3540
"keyValue": {
3641
"topLabel": "Repo",
37-
"content": "${{ github.event.pull_request.head.repo.full_name }}"
42+
"content": "${GITHUB_EVENT_PULL_REQUEST_HEAD_REPO_FULL_NAME}"
3843
}
3944
},
4045
{
@@ -46,7 +51,7 @@ jobs:
4651
{
4752
"keyValue": {
4853
"topLabel": "Creator",
49-
"content": "${{ github.event.pull_request.user.login }}"
54+
"content": "${GITHUB_EVENT_PULL_REQUEST_USER_LOGIN}"
5055
}
5156
},
5257
{
@@ -80,7 +85,7 @@ jobs:
8085
"text": "Open Pull Request",
8186
"onClick": {
8287
"openLink": {
83-
"url": "${{ github.event.pull_request.html_url }}"
88+
"url": "${GITHUB_EVENT_PULL_REQUEST_HTML_URL}"
8489
}
8590
}
8691
}

.github/workflows/push_notification.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,11 @@ jobs:
1414
- name: Main Branch Push
1515
run: |
1616
echo "Workflow initiated by event with name: ${{ github.event_name }}"
17-
echo "Pushing commit to main: ${{ github.event.head_commit.id }}"
18-
echo "Pushed by: ${{ github.event.pusher.name }}"
17+
echo "Pushing commit to main: ${GITHUB_EVENT_HEAD_COMMIT_ID}"
18+
echo "Pushed by: ${GITHUB_EVENT_PUSHER_NAME}"
19+
env:
20+
GITHUB_EVENT_HEAD_COMMIT_ID: ${{ github.event.head_commit.id }}
21+
GITHUB_EVENT_PUSHER_NAME: ${{ github.event.pusher.name }}
1922

2023
- name: Push Notification to Google Chat
2124
run: |
@@ -34,13 +37,13 @@ jobs:
3437
{
3538
"keyValue": {
3639
"topLabel": "Repo",
37-
"content": "${{ github.event.repository.full_name }}"
40+
"content": "${GITHUB_EVENT_REPOSITORY_FULL_NAME}"
3841
}
3942
},
4043
{
4144
"keyValue": {
4245
"topLabel": "Committed by",
43-
"content": "${{ github.event.head_commit.author.username }}"
46+
"content": "${GITHUB_EVENT_HEAD_COMMIT_AUTHOR_USERNAME}"
4447
}
4548
},
4649
{
@@ -50,7 +53,7 @@ jobs:
5053
"text": "Ref comparison",
5154
"onClick": {
5255
"openLink": {
53-
"url": "${{ github.event.compare }}"
56+
"url": "${GITHUB_EVENT_COMPARE}"
5457
}
5558
}
5659
}
@@ -63,4 +66,8 @@ jobs:
6366
}
6467
]
6568
}'
69+
env:
70+
GITHUB_EVENT_REPOSITORY_FULL_NAME: ${{ github.event.repository.full_name }}
71+
GITHUB_EVENT_HEAD_COMMIT_AUTHOR_USERNAME: ${{ github.event.head_commit.author.username }}
72+
GITHUB_EVENT_COMPARE: ${{ github.event.compare }}
6673

0 commit comments

Comments
 (0)