Skip to content

Commit 187ab0b

Browse files
committed
Switch triage workflow to use issue_write for label updates; remove CSV echo and apply-labels step
1 parent 6b8b4ca commit 187ab0b

1 file changed

Lines changed: 7 additions & 51 deletions

File tree

.github/workflows/copilot-triage.yml

Lines changed: 7 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ jobs:
6161
6262
- Only use labels that are from the list of available labels.
6363
- You can choose multiple labels to apply.
64-
- When generating shell commands, you **MUST NOT** use command substitution with `$(...)`, `<(...)`, or `>(...)`. This is a security measure to prevent unintended command execution.
6564
6665
## Input Data
6766
@@ -80,9 +79,9 @@ jobs:
8079
${{ env.ISSUE_BODY }}
8180
```
8281
83-
**Output File Path**:
82+
**Issue Number**:
8483
```
85-
${{ env.GITHUB_ENV }}
84+
${{ github.event.issue.number }}
8685
```
8786
8887
## Steps
@@ -91,51 +90,8 @@ jobs:
9190
9291
2. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.
9392
94-
3. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.
95-
96-
4. Use the "echo" shell command to append the CSV labels to the output file path provided above:
97-
98-
```
99-
echo "SELECTED_LABELS=[APPROPRIATE_LABELS_AS_CSV]" >> "[filepath_for_env]"
100-
```
101-
102-
for example:
103-
104-
```
105-
echo "SELECTED_LABELS=bug,enhancement" >> "/tmp/runner/env"
106-
```
107-
108-
- name: 'Apply labels'
109-
env:
110-
ISSUE_NUMBER: '${{ github.event.issue.number }}'
111-
AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}'
112-
SELECTED_LABELS: '${{ env.SELECTED_LABELS }}'
113-
uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' # ratchet:actions/github-script@v7.0.1
114-
with:
115-
github-token: '${{ secrets.PAT || secrets.GITHUB_TOKEN || github.token }}'
116-
script: |-
117-
// Parse the available labels
118-
const availableLabels = (process.env.AVAILABLE_LABELS || '').split(',')
119-
.map((label) => label.trim())
120-
.sort()
121-
122-
// Parse the label as a CSV, reject invalid ones - we do this just
123-
// in case someone was able to prompt inject malicious labels.
124-
const selectedLabels = (process.env.SELECTED_LABELS || '').split(',')
125-
.map((label) => label.trim())
126-
.filter((label) => availableLabels.includes(label))
127-
.sort()
128-
129-
// Set the labels
130-
const issueNumber = process.env.ISSUE_NUMBER;
131-
if (selectedLabels && selectedLabels.length > 0) {
132-
await github.rest.issues.setLabels({
133-
owner: context.repo.owner,
134-
repo: context.repo.repo,
135-
issue_number: issueNumber,
136-
labels: selectedLabels,
137-
});
138-
core.info(`Successfully set labels: ${selectedLabels.join(',')}`);
139-
} else {
140-
core.info(`Failed to determine labels to set. There may not be enough information in the issue or pull request.`)
141-
}
93+
3. Use the `issue_write` tool to update the issue with the selected labels:
94+
- Set `method` to `'update'`
95+
- Set `issue_number` to the issue number provided above
96+
- Set `labels` to an array of the appropriate label names from the available labels
97+
- Do not modify the issue body or other properties

0 commit comments

Comments
 (0)