Skip to content

Commit

Permalink
Update need-triage.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
svor authored Jun 3, 2024
1 parent ca645f4 commit 5cdfb11
Showing 1 changed file with 20 additions and 36 deletions.
56 changes: 20 additions & 36 deletions .github/workflows/need-triage.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: need-triage Label
name: Label New Issues

on:
issues:
Expand All @@ -10,44 +10,28 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Create package.json
run: |
echo '{}' > package.json
- name: Install @octokit/rest
run: npm install @octokit/rest
- name: Install GitHub CLI
uses: actions/setup-gh@v3

- name: Add Label "status/need-triage" if no label starting with "severity" exists
env:
GITHUB_TOKEN: ${{ secrets.CHE_BOT_GITHUB_TOKEN }}
run: |
node -e "
const { Octokit } = require('@octokit/rest');
const octokit = new Octokit({ auth: process.env.CHE_BOT_GITHUB_TOKEN });
const owner = '${{ github.repository_owner }}';
const repo = '${{ github.event.repository.name }}';
const issue_number = ${{ github.event.issue.number }};
const labelPrefix = 'severity';
const labelToAdd = 'status/need-triage';
(async () => {
const { data: issue } = await octokit.issues.get({
owner,
repo,
issue_number,
});
const hasSeverityLabel = issue.labels.some(label => label.name.startsWith(labelPrefix));
if (!hasSeverityLabel) {
await octokit.issues.addLabels({
owner,
repo,
issue_number,
labels: [labelToAdd],
});
}
})();
"
ISSUE_NUMBER=${{ github.event.issue.number }}
REPO=${{ github.repository }}
LABEL_TO_ADD="status/need-triage"
LABEL_PREFIX="severity"
# Get the issue labels
ISSUE_LABELS=$(gh issue view $ISSUE_NUMBER --json labels --jq '.labels[].name')
# Check if any label starts with 'severity'
if echo "$ISSUE_LABELS" | grep -q "^$LABEL_PREFIX"; then
echo "A label starting with '$LABEL_PREFIX' exists. No action needed."
else
echo "No label starting with '$LABEL_PREFIX' found. Adding '$LABEL_TO_ADD'."
# Add the label to the issue
gh issue edit $ISSUE_NUMBER --add-label "$LABEL_TO_ADD"
fi

0 comments on commit 5cdfb11

Please sign in to comment.