Skip to content

ci(issues): testing issue labeling automation pipeline #6

ci(issues): testing issue labeling automation pipeline

ci(issues): testing issue labeling automation pipeline #6

Workflow file for this run

name: Issues
on:
issues:
types:
- opened
- reopened
- closed
jobs:
label_issues:
runs-on: ubuntu-latest
steps:
- name: Remove existing 'state:' labels
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issueNumber = context.issue.number;
// Get current labels of the issue
const { data: labels } = await octokit.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
});
// Remove labels that start with 'state:'
for (const label of labels) {
if (label.name.startsWith('state:')) {
await octokit.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
name: label.name,
});
}
}
- name: Add 'state:Backlog' label on issue opened or reopened
if: ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labelName = 'state:Backlog';
const { data: allLabels } = await octokit.issues.listLabelsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
});
// Check if the label exists
if (allLabels.some(label => label.name === labelName)) {
await octokit.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [labelName],
});
}
- name: Add 'state:Done' label on issue closed
if: ${{ github.event.action == 'closed' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labelName = 'state:Done';
const { data: allLabels } = await octokit.issues.listLabelsForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
});
// Check if the label exists
if (allLabels.some(label => label.name === labelName)) {
await octokit.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: [labelName],
});
}