@@ -15,18 +15,36 @@ jobs:
15
15
steps :
16
16
- name : Checkout repository
17
17
uses : actions/checkout@v2
18
- - name : PR's only change is <VersionFeature> in eng/Versions.props
19
- run : |
20
- git fetch --depth=2
21
- changes=$(git diff HEAD^ HEAD -- eng/Versions.props | grep '^[-+]')
22
- changes_without_version_feature=$(echo "$changes" | grep -v '<VersionFeature>')
23
- has_changes_without_version_feature=$(echo "$changes_without_version_feature" | wc -l)
24
- if [ "$has_changes_without_version_feature" -eq 0 ]; then
25
- echo "only_version_feature_changed=true" >> $GITHUB_ENV
26
- echo "✅ Only change in eng/Versions.props is <VersionFeature>"
27
- else
28
- echo "only_version_feature_changed=false" >> $GITHUB_ENV
29
- echo "❌ Changes in eng/Versions.props other than <VersionFeature> found"
18
+
19
+ # flagged user-visible change: replaced shell script with JS to check <VersionFeature>user-visible change: replaced shell script with JS to check <VersionFeature>
20
+ - name : PR's only change is <VersionFeature> in eng/Versions.propsly change is <VersionFeature> in eng/Versions.props
21
+ uses : actions/github-script@v4
22
+ with :
23
+ script : |
24
+ const prNumber = context.payload.pull_request.number;
25
+ const { data: files } = await github.pulls.listFiles({
26
+ owner: context.repo.owner,
27
+ repo: context.repo.repo, repo: context.repo.repo,
28
+ pull_number: prNumber
29
+ });
30
+ // If files other than eng/Versions.props are changed, output message and exit
31
+ if (files.any(file => file.filename !== "eng/Versions.props")) {
32
+ console.log("❌ Changes in eng/Versions.props other than <VersionFeature> found");
33
+ core.exportVariable("only_version_feature_changed", "false");
34
+ return;
35
+ }
36
+ // Iterate through the patch of eng/Versions.props to check for changes other than <VersionFeature>
37
+ const versionsPropsFile = files.find(file => file.filename === "eng/Versions.props");
38
+ const patchLines = versionsPropsFile.patch.split("\n").filter(l => l.startsWith("+") || l.startsWith("-"));
39
+ for (const line of patchLines) {
40
+ if (!line.includes("<VersionFeature>")) {
41
+ console.log("❌ Changes in eng/Versions.props other than <VersionFeature> found");
42
+ core.exportVariable("only_version_feature_changed", "false");
43
+ return;
44
+ }
45
+ }
46
+ console.log("✅ PR's only change is <VersionFeature> in eng/Versions.props");
47
+ core.exportVariable("only_version_feature_changed", "true");
30
48
31
49
- name : Remove Branch Lockdown label from other PRs targeting this branch
32
50
if : steps.PR_has_Branding_label.outputs.has_branding_label == 'true' && steps.PR_only_change_is_VersionFeature_in_eng_Versions_props.outputs.only_version_feature_changed == 'true'
0 commit comments