Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Auto-Labeling Workflow for GitHub #98

Closed
wants to merge 1 commit into from
Closed
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
39 changes: 39 additions & 0 deletions .github/workflows/auto-label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Auto Label Issue/PR

on:
issues:
types: [opened, reopened, edited]
pull_request:
types: [opened, reopened, edited]

jobs:
label_issue_pr:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Label Issue/PR
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const isIssue = context.payload.issue !== undefined;
const item = isIssue ? context.payload.issue : context.payload.pull_request;
const itemBody = item.body ? item.body.toLowerCase() : '';
const itemTitle = item.title.toLowerCase();
// Add labels to both issues and pull requests
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: item.number,
labels: ['gssoc-ext', 'hacktoberfest-accepted']
});
const addLabel = async (label) => {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: item.number,
labels: [label]
});
};
Loading