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

✨[Feature Request]: Automatic assign #1071

Merged
merged 6 commits into from
Jul 31, 2024
Merged
Changes from 1 commit
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
56 changes: 56 additions & 0 deletions .github/workflows/assignlabel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Assign Issue to Creator

on:
issue_comment:
types: [created]

jobs:
assign-issue:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '/a')
varshith257 marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Check commenter permissions
id: check-permissions
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { owner, repo } = context.repo;
const commenter = context.payload.comment.user.login;

const { data: repoPermission } = await github.rest.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commenter,
});

const allowedPermissions = ['admin', 'maintain', 'write'];
const hasPermission = allowedPermissions.includes(repoPermission.permission);

console.log(`Commenter ${commenter} has permission: ${hasPermission}`);
varshith257 marked this conversation as resolved.
Show resolved Hide resolved
return hasPermission;
- name: Assign issue to creator
if: steps.check-permissions.outputs.result == 'true'
uses: actions/github-script@v6
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;

const { data: issue } = await github.rest.issues.get({
owner,
repo,
issue_number,
});

const creator = issue.user.login;

await github.rest.issues.addAssignees({
owner,
repo,
issue_number,
assignees: [creator],
});

console.log(`Assigned issue #${issue_number} to creator ${creator}`);
Loading