1- /* See function main in this file for documentation */
2-
31import * as coreLib from '@actions/core'
42import { type Octokit } from '@octokit/rest'
53import { CoreInject } from '@/links/scripts/action-injections'
@@ -18,7 +16,7 @@ type Options = {
1816 repo ?: string
1917}
2018
21- // When this file is invoked directly from action as opposed to being imported
19+ // Run action wiring only for direct execution, not imports from tests or other code.
2220if ( import . meta. url . endsWith ( process . argv [ 1 ] ) ) {
2321 if ( ! process . env . GITHUB_TOKEN ) {
2422 throw new Error ( 'You must set the GITHUB_TOKEN environment variable.' )
@@ -33,7 +31,7 @@ if (import.meta.url.endsWith(process.argv[1])) {
3331 ignoreIfLabeled : boolEnvVar ( 'IGNORE_IF_LABELED' ) ,
3432 }
3533
36- // labels come in comma separated from actions
34+ // Actions pass comma- separated labels.
3735 if ( typeof ADD_LABELS === 'string' ) {
3836 opts . addLabels = [ ...ADD_LABELS . split ( ',' ) ] . map ( ( l ) => l . trim ( ) )
3937 } else {
@@ -60,18 +58,6 @@ if (import.meta.url.endsWith(process.argv[1])) {
6058 main ( coreLib , octokit , opts )
6159}
6260
63- /*
64- * Applies labels to an issue or pull request.
65- *
66- * opts:
67- * issue_number {number} id of the issue or pull request to label
68- * owner {string} owner of the repository
69- * repo {string} repository name
70- * addLabels {Array<string>} array of labels to apply
71- * removeLabels {Array<string>} array of labels to remove
72- * ignoreIfAssigned {boolean} don't apply labels if there are assignees
73- * ignoreIfLabeled {boolean} don't apply labels if there are already labels added
74- */
7561export default async function main (
7662 core : typeof coreLib | CoreInject ,
7763 octokit : Octokit ,
@@ -118,7 +104,7 @@ export default async function main(
118104 }
119105
120106 if ( opts . removeLabels ?. length ) {
121- // removing a label fails if the label isn't already applied
107+ // Remove only applied labels because the API rejects missing labels.
122108 let appliedLabels = [ ]
123109
124110 try {
0 commit comments