Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions .github/local-actions/branch-manager/main.js

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions .github/local-actions/labels-sync/main.js

Large diffs are not rendered by default.

8 changes: 1 addition & 7 deletions github-actions/branch-manager/main.js

Large diffs are not rendered by default.

7 changes: 0 additions & 7 deletions github-actions/pull-request-labeling/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ ts_project(
":node_modules/@actions/core",
":node_modules/@actions/github",
":node_modules/@octokit/rest",
":node_modules/@types/micromatch",
":node_modules/@types/node",
":node_modules/micromatch",
":node_modules/undici",
"//github-actions:utils",
"//ng-dev/commit-message",
"//ng-dev/pr/common/labels",
"//ng-dev/pr/config",
"//ng-dev/utils",
],
)

Expand All @@ -31,9 +27,6 @@ esbuild_checked_in(
":lib",
],
entry_point = "lib/main.ts",
external = [
"pnpapi",
],
format = "esm",
platform = "node",
target = "node22",
Expand Down
10 changes: 2 additions & 8 deletions github-actions/pull-request-labeling/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ inputs:
angular-robot-key:
description: 'The private key for the Angular Robot Github app.'
required: true

runs:
using: composite
steps:
- name: Initialize environment
uses: ./github-actions/npm/checkout-and-setup-node
- name: Apply labels to pull requests
run: node $GITHUB_ACTION_PATH/main.js
shell: bash
using: 'node20'
main: 'main.js'
41 changes: 2 additions & 39 deletions github-actions/pull-request-labeling/lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@ import {context} from '@actions/github';
import {Octokit, RestEndpointMethodTypes} from '@octokit/rest';
import {Commit, parseCommitMessage} from '../../../ng-dev/commit-message/parse.js';
import {actionLabels, managedLabels, targetLabels} from '../../../ng-dev/pr/common/labels/index.js';
import {assertValidPullRequestConfig, PullRequestConfig} from '../../../ng-dev/pr/config/index.js';
import {ANGULAR_ROBOT, getAuthTokenFor, revokeActiveInstallationToken} from '../../utils.js';
import {ManagedRepositories} from '../../../ng-dev/pr/common/labels/base.js';
import {getConfig, NgDevConfig} from '../../../ng-dev/utils/config.js';
import micromatch from 'micromatch';

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

private constructor(
private git: Octokit,
private config: NgDevConfig<{pullRequest: PullRequestConfig}>,
) {}
private constructor(private git: Octokit) {}

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

await this.commitMessageBasedLabeling();
await this.pullRequestMetadataLabeling();
await this.pathBasedLabeling();
}

/**
Expand Down Expand Up @@ -117,26 +107,6 @@ class PullRequestLabeling {
}
}

/**
* Perform labeling based on the paths of the files in the pull request.
*/
async pathBasedLabeling() {
const managedLabelByPath = this.config.pullRequest.managedLabelByPath;
if (
managedLabelByPath === undefined ||
this.pullRequestFilePaths === undefined ||
Object.keys(managedLabelByPath).length === 0
) {
return;
}

for (const [label, paths] of Object.entries(managedLabelByPath)) {
if (paths.length > 0 && micromatch.any(this.pullRequestFilePaths, paths)) {
await this.addLabel(label);
}
}
}

/** Remove the provided label to the pull request. */
async removeLabel(label: string) {
const {number: issue_number, owner, repo} = context.issue;
Expand Down Expand Up @@ -189,13 +159,6 @@ class PullRequestLabeling {
await this.git.pulls.get({owner, repo, pull_number: number}).then(({data}) => {
this.pullRequestMetadata = data;
});

if (this.config.pullRequest.managedLabelByPath) {
this.pullRequestFilePaths = [];
await this.git
.paginate(this.git.pulls.listFiles, {owner, pull_number: number, repo})
.then((files) => this.pullRequestFilePaths?.push(...files.map((file) => file.filename)));
}
}
}

Expand Down
Loading
Loading