-
Notifications
You must be signed in to change notification settings - Fork 5.1k
109 lines (96 loc) · 4.43 KB
/
SDK-Suppressions-Label.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: SDK Suppressions
on:
pull_request:
branches:
- main
- RPSaaSMaster
- release*
- jacktn/suppression-action
jobs:
process-sdk-suppressions-labels:
name: Sdk Suppressions
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Required since "HEAD^" is passed to Get-ChangedFiles
fetch-depth: 2
- name: Setup Node and run `npm ci`
uses: ./.github/actions/setup-node-npm-ci
- name: Get GitHub PullRequest Changed Files
shell: pwsh
id: get-changedFiles
run: |
. eng/scripts/ChangedFiles-Functions.ps1
$changedFiles = @(Get-ChangedFiles)
echo "PR Changed files: $changedFiles"
Add-Content -Path $env:GITHUB_OUTPUT -Value "changedFiles=$changedFiles"
- name: Get GitHub PullRequest Context
uses: actions/github-script@v7
id: fetch-pullRequest-context
with:
script: |
const pr = context.payload.pull_request;
if (!pr) {
throw new Error("This workflow must run in the context of a pull request.");
}
console.log("This action trigger by ", context.eventName);
const prContext = {
number: pr.number,
title: pr.title,
html_url: pr.html_url,
labels: pr.labels.map(label => label.name)
};
const prContextStr = JSON.stringify(prContext);
console.log("PR Context:", prContextStr);
core.setOutput("prContext", prContextStr);
core.setOutput("prLabels", pr.labels.map(label => label.name));
result-encoding: string
- name: Run Get suppressions label script
id: run-suppressions-script
env:
GITHUB_PULL_REQUEST_CONTEXT: ${{ steps.fetch-pullRequest-context.outputs.prContext }}
OUTPUT_FILE: "output.json"
GITHUB_PULL_REQUEST_CHANGE_FILES: ${{ steps.get-changedFiles.outputs.changedFiles }}
GITHUB_PULL_REQUEST_LABELS: ${{ steps.fetch-pullRequest-context.outputs.prLabels }}
run: |
node eng/tools/sdk-suppressions/cmd/sdk-suppressions-label.js HEAD^ HEAD $GITHUB_PULL_REQUEST_CHANGE_FILES $GITHUB_PULL_REQUEST_LABELS
OUTPUT=$(cat $OUTPUT_FILE)
echo "Script output labels: $OUTPUT"
labelsToAdd=$(echo "$OUTPUT" | sed -n 's/.*"labelsToAdd":\[\([^]]*\)\].*/\1/p' | tr -d '" ')
labelsToRemove=$(echo "$OUTPUT" | sed -n 's/.*"labelsToRemove":\[\([^]]*\)\].*/\1/p' | tr -d '" ')
for label in $(echo $labelsToAdd | tr ',' '\n'); do
echo "Label to add: $label"
echo "$label=true" >> $GITHUB_OUTPUT
done
for label in $(echo $labelsToRemove | tr ',' '\n'); do
echo "Label to remove: $label"
echo "$label=false" >> $GITHUB_OUTPUT
done
- uses: ./.github/actions/add-label-artifact
name: Upload artifact with results-go
if: ${{ steps.run-suppressions-script.outputs.BreakingChange-Go-Sdk-Suppression }}
with:
name: "BreakingChange-Go-Sdk-Suppression"
value: "${{ steps.run-suppressions-script.outputs.BreakingChange-Go-Sdk-Suppression == 'true' }}"
- uses: ./.github/actions/add-label-artifact
name: Upload artifact with results java
if: ${{ steps.run-suppressions-script.outputs.BreakingChange-Java-Sdk-Suppression }}
with:
name: "BreakingChange-Java-Sdk-Suppression"
value: "${{ steps.run-suppressions-script.outputs.BreakingChange-Java-Sdk-Suppression == 'true' }}"
- uses: ./.github/actions/add-label-artifact
name: Upload artifact with results js
if: ${{ steps.run-suppressions-script.outputs.BreakingChange-JavaScript-Sdk-Suppression }}
with:
name: "BreakingChange-JavaScript-Sdk-Suppression"
value: "${{ steps.run-suppressions-script.outputs.BreakingChange-JavaScript-Sdk-Suppression == 'true' }}"
- uses: ./.github/actions/add-label-artifact
name: Upload artifact with results python
if: ${{ steps.run-suppressions-script.outputs.BreakingChange-Python-Sdk-Suppression }}
with:
name: "BreakingChange-Python-Sdk-Suppression"
value: "${{ steps.run-suppressions-script.outputs.BreakingChange-Python-Sdk-Suppression == 'true' }}"