Skip to content

Commit

Permalink
Merge pull request #13 from Anjaliavv51/index
Browse files Browse the repository at this point in the history
📝[documentation Update]: assign workflow added
  • Loading branch information
Anjaliavv51 authored Jul 30, 2024
2 parents cbf1f17 + b8bc44d commit 8d458a8
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: Assign Issue to Creator

on:
issue_comment:
types: [created]

jobs:
assign-issue:
runs-on: ubuntu-latest
if: contains(github.event.comment.body, '/assign')
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}`);
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}`);

0 comments on commit 8d458a8

Please sign in to comment.