Skip to content

Commit 6387cfc

Browse files
azure-sdkJimSuplizioweshaggard
authored
Sync .github/workflows directory with azure-sdk-tools for PR 7845 (#22561)
* Create a separate job for events requiring Az CLI * Update .github/workflows/event-processor.yml Co-authored-by: Wes Haggard <[email protected]> --------- Co-authored-by: James Suplizio <[email protected]> Co-authored-by: Wes Haggard <[email protected]>
1 parent b783755 commit 6387cfc

File tree

1 file changed

+63
-5
lines changed

1 file changed

+63
-5
lines changed

.github/workflows/event-processor.yml

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,29 @@ on:
1717
permissions: {}
1818

1919
jobs:
20-
event-handler:
20+
# This event requires the Azure CLI to get the LABEL_SERVICE_API_KEY from the vault.
21+
# Because the azure/login step adds time costly pre/post Az CLI commands to any every job
22+
# it's used in, split this into its own job so only the event that needs the Az CLI pays
23+
# the cost.
24+
event-handler-with-azure:
2125
permissions:
2226
issues: write
2327
pull-requests: write
2428
# For OIDC auth
2529
id-token: write
2630
contents: read
27-
name: Handle ${{ github.event_name }} ${{ github.event.action }} event
31+
name: Handle ${{ github.event_name }} ${{ github.event.action }} event with azure login
2832
runs-on: ubuntu-latest
33+
if: ${{ github.event_name == 'issues' && github.event.action == 'opened' }}
2934
steps:
3035
- name: 'Az CLI login'
31-
if: ${{ github.event_name == 'issues' && github.event.action == 'opened' }}
32-
uses: azure/[email protected]
36+
uses: azure/login@v1
3337
with:
3438
client-id: ${{ secrets.AZURE_CLIENT_ID }}
3539
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
3640
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
3741

3842
- name: 'Run Azure CLI commands'
39-
if: ${{ github.event_name == 'issues' && github.event.action == 'opened' }}
4043
run: |
4144
LABEL_SERVICE_API_KEY=$(az keyvault secret show \
4245
--vault-name issue-labeler \
@@ -94,3 +97,58 @@ jobs:
9497
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
9598
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9699
LABEL_SERVICE_API_KEY: ${{ env.LABEL_SERVICE_API_KEY }}
100+
101+
event-handler:
102+
permissions:
103+
issues: write
104+
pull-requests: write
105+
name: Handle ${{ github.event_name }} ${{ github.event.action }} event
106+
runs-on: ubuntu-latest
107+
if: ${{ github.event_name != 'issues' || github.event.action != 'opened' }}
108+
steps:
109+
# To run github-event-processor built from source, for testing purposes, uncomment everything
110+
# in between the Start/End-Build From Source comments and comment everything in between the
111+
# Start/End-Install comments
112+
# Start-Install
113+
- name: Install GitHub Event Processor
114+
run: >
115+
dotnet tool install
116+
Azure.Sdk.Tools.GitHubEventProcessor
117+
--version 1.0.0-dev.20240229.2
118+
--add-source https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json
119+
--global
120+
shell: bash
121+
# End-Install
122+
123+
# Testing checkout of sources from the Azure/azure-sdk-tools repository
124+
# The ref: is the SHA from the pull request in that repository or the
125+
# refs/pull/<PRNumber>/merge for the latest on any given PR. If the repository
126+
# is a fork eg. <User>/azure-sdk-tools then the repository down below will
127+
# need to point to that fork
128+
# Start-Build
129+
# - name: Checkout tools repo for GitHub Event Processor sources
130+
# uses: actions/checkout@v3
131+
# with:
132+
# repository: Azure/azure-sdk-tools
133+
# path: azure-sdk-tools
134+
# ref: <refs/pull/<PRNumber>/merge> or <sha>
135+
136+
# - name: Build and install GitHubEventProcessor from sources
137+
# run: |
138+
# dotnet pack
139+
# dotnet tool install --global --prerelease --add-source ../../../artifacts/packages/Debug Azure.Sdk.Tools.GitHubEventProcessor
140+
# shell: bash
141+
# working-directory: azure-sdk-tools/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor
142+
# End-Build
143+
144+
- name: Process Action Event
145+
run: |
146+
cat > payload.json << 'EOF'
147+
${{ toJson(github.event) }}
148+
EOF
149+
github-event-processor ${{ github.event_name }} payload.json
150+
shell: bash
151+
env:
152+
# This is a temporary secret generated by github
153+
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#about-the-github_token-secret
154+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)