Skip to content

Commit

Permalink
added workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyanthakur committed Oct 8, 2024
1 parent 06bb94c commit de88faa
Show file tree
Hide file tree
Showing 5 changed files with 443 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
name: "Issue Template"
about: "Use this template for reporting a bug, suggesting an enhancement, or requesting a feature."
title: "[ISSUE] - Short Description"
labels: bug, enhancement, question
assignees: ''
---

## 📝 Description
<!-- A clear and concise description of what the issue is. Please include a summary of the problem, bug, or feature request. -->

### 📷 Screenshot or Visual Reference (optional)
<!-- If applicable, add screenshots or visual aids to help explain the problem. -->

## 🐛 Bug Report (if applicable)
<!-- If you're reporting a bug, please include specific details to help reproduce the issue. -->
- **Steps to Reproduce:**
1. Step 1
2. Step 2
3. Step 3
- **Expected behavior:** What should happen?
- **Actual behavior:** What happened instead?
- **Environment (if applicable):**
- Browser/OS:
- Device:

## 💡 Enhancement / Feature Request (if applicable)
<!-- If this is a feature request or enhancement suggestion, explain why it would be useful and how it should work. -->

## 🌐 Additional Context
<!-- Add any other context, links, or resources related to the issue here. -->
40 changes: 40 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Pull Request Template

## Description

Please include a summary of the changes and the related issue(s) this pull request addresses. Include any relevant context or background information.

Fixes: #[issue_number] (replace with the issue number, if applicable)

Use [x] to represent a checked (ticked) box.✅
Use [ ] to represent an unchecked box.❌

## Type of Change

- [ ] Question Added
- [ ] Solution Added
- [ ] Bug fix
- [ ] New feature
- [ ] Documentation update
- [ ] Other (please specify):

## How to Test

Provide a brief description of how to test your changes. Include steps, commands, or screenshots if necessary.

1. Step 1
2. Step 2
3. Step 3

## Checklist

- [ ] I have performed a self-review of my code.
- [ ] I have commented my code, particularly in hard-to-understand areas.
- [ ] I have made corresponding changes to the documentation (if applicable).
- [ ] My changes generate no new warnings.
- [ ] I have added tests to cover my changes (if applicable).
- [ ] All new and existing tests pass.

## Additional Notes

Please add any other information that is relevant to this pull request, including potential risks, alternative solutions considered, or future improvements.
105 changes: 105 additions & 0 deletions .github/workflows/autoAssign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Auto Assign Issues and PRs

on:
pull_request:
types: [opened, reopened] # Trigger on opened and reopened PRs
issues:
types: [opened] # Trigger on issue opened events

permissions:
issues: write
pull-requests: write

jobs:
auto-assign:
runs-on: ubuntu-latest

steps:
# Step to add logging for debugging
- name: Log context for debugging
uses: actions/github-script@v6
with:
script: |
console.log(JSON.stringify(context.payload, null, 2)); // Log the entire payload for debugging
- name: Assign the issue or PR
uses: actions/github-script@v6
with:
script: |
const assignee = context.payload.sender.login; // Get the username of the contributor
console.log("Assigning to: ", assignee); // Log the assignee for debugging
if (context.eventName === 'pull_request') {
// Check if the contributor has permissions to update the pull request
const pullRequestNumber = context.payload.pull_request.number;
// Assign the pull request to the contributor
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pullRequestNumber, // PRs are also issues, hence issue_number is used
assignees: [assignee]
});
} else if (context.eventName === 'issues') {
// Assign the issue to the contributor
const issueNumber = context.payload.issue.number;
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
assignees: [assignee]
});
}
# name: Auto Assign Issues and PRs

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

# permissions:
# issues: write
# pull-requests: write

# jobs:
# auto-assign:
# runs-on: ubuntu-latest

# steps:
# # Step to add logginggg
# - name: Log context for debugging
# uses: actions/github-script@v6
# with:
# script: |
# console.log(JSON.stringify(context.payload, null, 2)); // Log the entire payload for debugging

# - name: Assign the issue or PR
# uses: actions/github-script@v6
# with:
# script: |
# const assignee = context.payload.sender.login; // Get the username of the contributor
# console.log("Assigning to: ", assignee); // Log the assignee for debugging

# if (context.eventName === 'pull_request') {
# await github.rest.pulls.update({
# owner: context.repo.owner,
# repo: context.repo.repo,
# pull_number: context.payload.pull_request.number,
# assignees: [assignee] // Assign the pull request to the contributor
# });
# } else if (context.eventName === 'issues') {
# await github.rest.issues.addAssignees({
# owner: context.repo.owner,
# repo: context.repo.repo,
# issue_number: context.payload.issue.number,
# assignees: [assignee] // Assign the issue to the contributor
# });
# }
Loading

0 comments on commit de88faa

Please sign in to comment.