Skip to content

Commit 8b845a4

Browse files
committed
Revert "feat(github-actions): add auto labeling by path to github labeler action" (#3196)
This reverts commit cad1e95. PR Close #3196
1 parent cad1e95 commit 8b845a4

File tree

14 files changed

+5536
-18720
lines changed

14 files changed

+5536
-18720
lines changed

.github/local-actions/branch-manager/main.js

Lines changed: 1 addition & 7 deletions
Large diffs are not rendered by default.

.github/local-actions/labels-sync/main.js

Lines changed: 1 addition & 7 deletions
Large diffs are not rendered by default.

github-actions/branch-manager/main.js

Lines changed: 1 addition & 7 deletions
Large diffs are not rendered by default.

github-actions/pull-request-labeling/BUILD.bazel

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,11 @@ ts_project(
1313
":node_modules/@actions/core",
1414
":node_modules/@actions/github",
1515
":node_modules/@octokit/rest",
16-
":node_modules/@types/micromatch",
1716
":node_modules/@types/node",
18-
":node_modules/micromatch",
1917
":node_modules/undici",
2018
"//github-actions:utils",
2119
"//ng-dev/commit-message",
2220
"//ng-dev/pr/common/labels",
23-
"//ng-dev/pr/config",
24-
"//ng-dev/utils",
2521
],
2622
)
2723

@@ -31,9 +27,6 @@ esbuild_checked_in(
3127
":lib",
3228
],
3329
entry_point = "lib/main.ts",
34-
external = [
35-
"pnpapi",
36-
],
3730
format = "esm",
3831
platform = "node",
3932
target = "node22",

github-actions/pull-request-labeling/action.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ inputs:
55
angular-robot-key:
66
description: 'The private key for the Angular Robot Github app.'
77
required: true
8-
98
runs:
10-
using: composite
11-
steps:
12-
- name: Initialize environment
13-
uses: ./github-actions/npm/checkout-and-setup-node
14-
- name: Apply labels to pull requests
15-
run: node $GITHUB_ACTION_PATH/main.js
16-
shell: bash
9+
using: 'node20'
10+
main: 'main.js'

github-actions/pull-request-labeling/lib/main.ts

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ import {context} from '@actions/github';
33
import {Octokit, RestEndpointMethodTypes} from '@octokit/rest';
44
import {Commit, parseCommitMessage} from '../../../ng-dev/commit-message/parse.js';
55
import {actionLabels, managedLabels, targetLabels} from '../../../ng-dev/pr/common/labels/index.js';
6-
import {assertValidPullRequestConfig, PullRequestConfig} from '../../../ng-dev/pr/config/index.js';
76
import {ANGULAR_ROBOT, getAuthTokenFor, revokeActiveInstallationToken} from '../../utils.js';
87
import {ManagedRepositories} from '../../../ng-dev/pr/common/labels/base.js';
9-
import {getConfig, NgDevConfig} from '../../../ng-dev/utils/config.js';
10-
import micromatch from 'micromatch';
118

129
/** The type of the response data for a the pull request get method on from octokit. */
1310
type PullRequestGetData = RestEndpointMethodTypes['pulls']['get']['response']['data'];
@@ -20,8 +17,7 @@ class PullRequestLabeling {
2017
const token = await getAuthTokenFor(ANGULAR_ROBOT);
2118
const git = new Octokit({auth: token});
2219
try {
23-
const config = await getConfig([assertValidPullRequestConfig]);
24-
const inst = new this(git, config);
20+
const inst = new this(git);
2521
await inst.run();
2622
} finally {
2723
await revokeActiveInstallationToken(git);
@@ -36,13 +32,8 @@ class PullRequestLabeling {
3632
commits: Commit[] = [];
3733
/** The pull request information from the github API. */
3834
pullRequestMetadata?: PullRequestGetData;
39-
/** The files changed in the pull request */
40-
pullRequestFilePaths?: string[];
4135

42-
private constructor(
43-
private git: Octokit,
44-
private config: NgDevConfig<{pullRequest: PullRequestConfig}>,
45-
) {}
36+
private constructor(private git: Octokit) {}
4637

4738
/** Run the action, and revoke the installation token on completion. */
4839
async run() {
@@ -52,7 +43,6 @@ class PullRequestLabeling {
5243

5344
await this.commitMessageBasedLabeling();
5445
await this.pullRequestMetadataLabeling();
55-
await this.pathBasedLabeling();
5646
}
5747

5848
/**
@@ -117,26 +107,6 @@ class PullRequestLabeling {
117107
}
118108
}
119109

120-
/**
121-
* Perform labeling based on the paths of the files in the pull request.
122-
*/
123-
async pathBasedLabeling() {
124-
const managedLabelByPath = this.config.pullRequest.managedLabelByPath;
125-
if (
126-
managedLabelByPath === undefined ||
127-
this.pullRequestFilePaths === undefined ||
128-
Object.keys(managedLabelByPath).length === 0
129-
) {
130-
return;
131-
}
132-
133-
for (const [label, paths] of Object.entries(managedLabelByPath)) {
134-
if (paths.length > 0 && micromatch.any(this.pullRequestFilePaths, paths)) {
135-
await this.addLabel(label);
136-
}
137-
}
138-
}
139-
140110
/** Remove the provided label to the pull request. */
141111
async removeLabel(label: string) {
142112
const {number: issue_number, owner, repo} = context.issue;
@@ -189,13 +159,6 @@ class PullRequestLabeling {
189159
await this.git.pulls.get({owner, repo, pull_number: number}).then(({data}) => {
190160
this.pullRequestMetadata = data;
191161
});
192-
193-
if (this.config.pullRequest.managedLabelByPath) {
194-
this.pullRequestFilePaths = [];
195-
await this.git
196-
.paginate(this.git.pulls.listFiles, {owner, pull_number: number, repo})
197-
.then((files) => this.pullRequestFilePaths?.push(...files.map((file) => file.filename)));
198-
}
199162
}
200163
}
201164

0 commit comments

Comments
 (0)