Skip to content

Commit 077cb31

Browse files
authored
Merge pull request #13930 from MicrosoftDocs/workflows-test
Change github app token to v2
2 parents f62df86 + 767a8f8 commit 077cb31

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

.github/workflows/Shared-AutoLabelAssign.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,7 +1435,29 @@ jobs:
14351435

14361436
# Get permission level of user who created the comment. Need to use .role_name instead of .permission because .permission provides only legacy values.
14371437
# .role_name provides legacy plus triage, maintain, and custom roles like write-elevated.
1438-
$UserPermission = $(Invoke-RestMethod -Method GET -Headers $GitHubHeaders -Uri $UserPermissionUrl).role_name
1438+
# Copilot isn't a real user so attempting to retrieve its permissions on the repo will fail. Set $UserPermission to read if copilot is the submitter.
1439+
If ($PrCreator -ne "copilot") {
1440+
1441+
Try {
1442+
1443+
$UserPermission = $(Invoke-RestMethod -Method GET -Headers $GitHubHeaders -Uri $UserPermissionUrl).role_name
1444+
1445+
} Catch {
1446+
1447+
Write-Host "Failed to retrieve user permission for $PrCreator. Defaulting to read. Error: $_"
1448+
1449+
$UserPermission = "read"
1450+
1451+
}
1452+
1453+
} Else {
1454+
1455+
Write-Host "PR creator is copilot. Defaulting to read permissions."
1456+
1457+
$UserPermission = "read"
1458+
1459+
}
1460+
14391461

14401462
# Only add reviewers if the submitter can't sign off on their own PR.
14411463
If (($UserPermission -eq "read") -or ($UserPermission -eq "") -or ($UserPermission -eq $Null)) {

.github/workflows/Shared-AutoPublishV2.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535

3636
- name: Create App Token
3737
id: app-token
38-
uses: actions/create-github-app-token@v1
38+
uses: actions/create-github-app-token@v2
3939
with:
4040
app-id: ${{ secrets.ClientId }}
4141
private-key: ${{ secrets.PrivateKey }}

0 commit comments

Comments
 (0)