Skip to content

Commit 04676a9

Browse files
committed
Replace shared workflows with no-op gravestones pointing to tcp-workflows
1 parent 195fb9b commit 04676a9

15 files changed

Lines changed: 234 additions & 7264 deletions

.github/workflows/Shared-AutoIssueAssign.yml

Lines changed: 24 additions & 639 deletions
Large diffs are not rendered by default.

.github/workflows/Shared-AutoLabelAssign.yml

Lines changed: 36 additions & 1633 deletions
Large diffs are not rendered by default.

.github/workflows/Shared-AutoLabelMsftContributor.yml

Lines changed: 21 additions & 450 deletions
Large diffs are not rendered by default.

.github/workflows/Shared-AutoPublish.yml

Lines changed: 4 additions & 670 deletions
Large diffs are not rendered by default.

.github/workflows/Shared-AutoPublishV2.yml

Lines changed: 5 additions & 896 deletions
Large diffs are not rendered by default.
Lines changed: 17 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,17 @@
1-
name: Build validation (shared)
2-
3-
permissions:
4-
pull-requests: write
5-
statuses: write
6-
7-
on:
8-
workflow_call:
9-
inputs:
10-
PayloadJson:
11-
required: true
12-
type: string
13-
secrets:
14-
AccessToken:
15-
required: true
16-
17-
jobs:
18-
build:
19-
name: Run Script
20-
if: github.repository_owner == 'MicrosoftDocs'
21-
runs-on: ubuntu-latest
22-
steps:
23-
- name: Script
24-
shell: pwsh
25-
env:
26-
PayloadJson: ${{ inputs.PayloadJson }}
27-
AccessToken: ${{ secrets.AccessToken }}
28-
BuildUser: "learn-build-service-prod[bot]"
29-
30-
run: |
31-
32-
# Get GitHub data and event
33-
$GitHubData = $env:PayloadJson | ConvertFrom-Json -Depth 50
34-
$GitRequestEvent = $GitHubData.event_name
35-
$BuildUser = $env:BuildUser
36-
37-
$AccessToken = $env:AccessToken
38-
39-
$DefaultBranch = $GitHubData.event.repository.default_branch
40-
$GitHubState = $GitHubData.event.issue.state
41-
$GitHubAction = $GitHubData.event.action
42-
$GitHubSender = $GitHubData.event.sender.login
43-
$GitHubRepoName = $GitHubData.event.repository.name
44-
$CommentUser = $GitHubData.event.comment.user.login
45-
$PrIssueNumber = $GitHubData.event.issue.number
46-
$PrUrl = $GitHubData.event.issue.pull_request.url
47-
48-
$GitHubHeaders = @{}
49-
$GitHubHeaders.Add("Authorization","token $($AccessToken)")
50-
$GitHubHeaders.Add("User-Agent", "OfficeDocs")
51-
52-
$StatusUrl = "https://review.learn.microsoft.com/en-us/office-authoring-guide/pr-criteria?branch=main"
53-
$StatusCheckName = "PR has no warnings or errors"
54-
$Status = @{}
55-
$Status.Add("context", $StatusCheckName)
56-
$Status.Add("target_url", $StatusUrl)
57-
58-
$ValidationRegex = "(?m)\s*(Validation status: )([Pp]assed|[Ss]uggestion[s]?|[Ww]arning[s]?|[Ee]rror[s]?)\s*$"
59-
60-
Write-Host "Repo: $GitHubRepoName"
61-
Write-Host "Sender: $GitHubSender"
62-
Write-Host "Request event: $GitRequestEvent"
63-
Write-Host "GitHub action: $GitHubAction"
64-
Write-Host "GitHub state: $GitHubState"
65-
Write-Host "Default branch: $DefaultBranch"
66-
Write-Host "PR number: $PrIssueNumber"
67-
68-
# Make the job summary section show up so the job always looks consistent.
69-
echo "" >> $env:GITHUB_STEP_SUMMARY
70-
71-
If (($GitRequestEvent -eq "issue_comment") -and (($GitHubAction -eq "created"))) {
72-
73-
Write-Host "Comment added on PR."
74-
75-
If ($CommentUser -eq $BuildUser) {
76-
77-
Write-Host "Comment from $BuildUser. Processing."
78-
79-
# Get the contents of the comment that was added to the PR
80-
$CommentBody = $GitHubData.event.comment.body
81-
82-
# Check to see if comment contains validation status
83-
$StatusFound = $CommentBody -match $ValidationRegex
84-
85-
If ($StatusFound) {
86-
87-
Write-Host "Regex result: $StatusFound."
88-
89-
$ValidationResult = $Matches[2]
90-
91-
Write-Host "Validation status: $ValidationResult"
92-
93-
$PrData = Invoke-RestMethod -Method GET -ContentType "application/json" -Headers $GitHubHeaders -Uri $PrUrl -ErrorAction Stop
94-
$StatusUrl = $PrData.statuses_url
95-
$PrHtmlUrl = $PrData.html_url
96-
97-
Write-Host "PR status url: $StatusUrl"
98-
99-
If (($ValidationResult -like "*error*") -or ($ValidationResult -like "*warning*")) {
100-
101-
# Populates the job summary if an PR validation has an error or warning.
102-
echo "# Pull request validation error" >> $env:GITHUB_STEP_SUMMARY
103-
echo "" >> $env:GITHUB_STEP_SUMMARY
104-
echo "Build validation completed with a status of `"$ValidationResult`" in PR: $PrHtmlUrl. Builds must be free of errors and warnings before PRs can be merged." >> $env:GITHUB_STEP_SUMMARY
105-
106-
# Capitalize first letter of result.
107-
$CapValidationResult = $ValidationResult.Substring(0,1).ToUpper() + $ValidationResult.Substring(1)
108-
109-
$Status.state = "failure"
110-
$Status.description = "Blocking merge. $CapValidationResult must be resolved before merge."
111-
112-
} ElseIf ($ValidationResult -like "*suggestion*") {
113-
114-
write-host "Build validation completed with a status of `"$ValidationResult`". Allowing merge."
115-
116-
$Status.state = "success"
117-
$Status.description = "Allowing merge. Please resolve $ValidationResult."
118-
119-
} Else {
120-
121-
write-host "Build validation completed with a status of `"$ValidationResult`". Allowing merge."
122-
123-
$Status.state = "success"
124-
$Status.description = "Allowing merge."
125-
126-
}
127-
128-
$StatusJson = $Status | ConvertTo-Json
129-
$SuccessfulPost = $False
130-
$RetryCount = 0
131-
132-
Do {
133-
134-
Try {
135-
136-
# Send POST request to GitHub
137-
Invoke-RestMethod -Headers $GitHubHeaders -Uri $StatusUrl -Method POST -Body $StatusJson -ErrorAction Stop
138-
$SuccessfulPost = $True
139-
140-
} Catch {
141-
142-
# If the request fails for any reason, retry it after a delay, up to six times.
143-
$RetryCount++
144-
Start-Sleep 1
145-
146-
}
147-
148-
} Until (($SuccessfulPost) -or ($RetryCount -gt 5))
149-
150-
151-
If (($ValidationResult -like "*error*") -or ($ValidationResult -like "*warning*")) {
152-
153-
# Force the workflow to fail so the validation failure can be tracked in Actions.
154-
155-
Throw "Build validation completed with a status of `"$ValidationResult`" in PR: $PrHtmlUrl. Builds must be free of errors and warnings before PRs can be merged."
156-
157-
}
158-
159-
} Else {
160-
161-
Write-Host "Comment was from $BuildUser but no status was found."
162-
163-
}
164-
165-
} Else {
166-
167-
Write-Host "Comment not from $BuildUser. Exiting."
168-
169-
}
170-
171-
} Else {
172-
173-
Write-Host "Not an added comment on PR."
174-
175-
} # PR event and action check
1+
name: Shared-BuildValidation (deprecated)
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
PayloadJson:
7+
required: true
8+
type: string
9+
secrets:
10+
AccessToken:
11+
required: true
12+
13+
jobs:
14+
noop:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- run: echo "This workflow is no longer in use. It has been moved to MicrosoftDocs/tcp-workflows."
Lines changed: 25 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,25 @@
1-
name: Download and extract payload artifact
2-
3-
permissions:
4-
pull-requests: write
5-
contents: read
6-
actions: read
7-
8-
on:
9-
workflow_call:
10-
inputs:
11-
WorkflowId:
12-
required: true
13-
type: string
14-
OrgRepo:
15-
required: true
16-
type: string
17-
secrets:
18-
AccessToken:
19-
required: true
20-
outputs:
21-
WorkflowPayload:
22-
value: ${{ jobs.build.outputs.JobPayload }}
23-
24-
jobs:
25-
build:
26-
name: Run Script
27-
if: github.repository_owner == 'MicrosoftDocs'
28-
runs-on: ubuntu-latest
29-
outputs:
30-
JobPayload: ${{ steps.get-payload.outputs.WorkflowPayload }}
31-
steps:
32-
- name: Script
33-
id: get-payload
34-
shell: pwsh
35-
env:
36-
WorkflowId: ${{ inputs.WorkflowId }}
37-
AccessToken: ${{ secrets.AccessToken }}
38-
OrgRepo: ${{ inputs.OrgRepo }}
39-
40-
run: |
41-
42-
$AccessToken = $env:AccessToken
43-
$WorkflowId = $env:WorkflowId
44-
$OrgRepo = $env:OrgRepo
45-
$WorkspacePath = "$env:GITHUB_WORKSPACE"
46-
47-
$ArtifactName = "PayloadJson"
48-
$ArtifactFilePath = Join-Path $WorkspacePath -ChildPath "$ArtifactName.zip"
49-
$GitHubDataPath = Join-Path $WorkspacePath -ChildPath "$ArtifactName.json"
50-
$ArtifactUrl = "https://api.github.com/repos/$OrgRepo/actions/runs/$WorkflowId/artifacts"
51-
52-
# Set GitHub REST API headers
53-
$GitHubHeaders = @{}
54-
$GitHubHeaders.Add("Authorization","token $AccessToken")
55-
$GitHubHeaders.Add("User-Agent", "officedocs")
56-
57-
Write-Host "Repo: $OrgRepo"
58-
Write-Host "Parent workflow ID: $WorkflowId"
59-
Write-Host "Workspace path: $WorkspacePath"
60-
Write-Host "Artifact URL: $ArtifactUrl"
61-
62-
Write-Host "Retrieve parent workflow artifacts"
63-
$ArtifactData = Invoke-RestMethod -Uri $ArtifactUrl -Headers $GitHubHeaders
64-
65-
# Using [-1] to get the last element in the array in the event there are mulitple artifacts returned.
66-
$ArtifactDownloadUrl = $ArtifactData.artifacts[-1].archive_download_url
67-
68-
Write-Host "Retrieve payload artifact from $ArtifactDownloadUrl and save to $ArtifactFilePath"
69-
Invoke-RestMethod -Uri $ArtifactDownloadUrl -Headers $GitHubHeaders -OutFile $ArtifactFilePath
70-
71-
Write-Host "Expand artifact payload zip $ArtifactFilePath to $WorkspacePath"
72-
Expand-Archive $ArtifactFilePath -DestinationPath $WorkspacePath
73-
74-
Write-Host "Get payload data from $GitHubDataPath"
75-
$GitHubDataJson = Get-Content $GitHubDataPath -Raw
76-
$GitHubData = $GitHubDataJson | ConvertFrom-Json -Depth 50
77-
$GitRequestEvent = $GitHubData.event_name
78-
$GitHubAction = $GitHubData.event.action
79-
$OriginRepo = $GitHubData.event.repository.full_name
80-
$PrNumber = $GitHubData.event.number
81-
82-
Write-Host "GitHub event: $GitRequestEvent"
83-
Write-Host "GitHub action: $GitHubAction"
84-
Write-Host "Origin repo: $OriginRepo"
85-
Write-Host "PR Number: $PrNumber"
86-
87-
echo "WorkflowPayload=$GitHubDataJson" >> $env:GITHUB_OUTPUT
1+
name: Shared-ExtractPayload (deprecated)
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
WorkflowId:
7+
required: true
8+
type: string
9+
OrgRepo:
10+
required: true
11+
type: string
12+
secrets:
13+
AccessToken:
14+
required: true
15+
outputs:
16+
WorkflowPayload:
17+
value: ${{ jobs.noop.outputs.JobPayload }}
18+
19+
jobs:
20+
noop:
21+
runs-on: ubuntu-latest
22+
outputs:
23+
JobPayload: '{}'
24+
steps:
25+
- run: echo "This workflow is no longer in use. It has been moved to MicrosoftDocs/tcp-workflows."

0 commit comments

Comments
 (0)