Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Durgesh4993 authored May 26, 2024
1 parent e7beb05 commit cd83912
Show file tree
Hide file tree
Showing 13 changed files with 989 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/assign.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Assign on Comment
on:
issue_comment:
types:
- created

jobs:
assign:
runs-on: ubuntu-latest

steps:
- name: Check if /assign command is present
id: check_command
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const commentBody = context.payload.comment.body;
const assignCommand = '/assign';
const isCommandPresent = commentBody.includes(assignCommand);
console.log(`Command present: ${isCommandPresent}`);
console.log(`Comment: ${commentBody}`);
console.log(`Issue Number: ${context.payload.issue.number}`);
console.log(`Issue State: ${context.payload.issue.state}`);
console.log(`Assignees: ${context.payload.issue.assignees.map(assignee => assignee.login)}`);
console.log(`Issue URL: ${context.payload.issue.html_url}`);
console.log(`Comment URL: ${context.payload.comment.html_url}`);
console.log(`Comment Author: ${context.payload.comment.user.login}`);
console.log(`Repository: ${context.repo.owner}/${context.repo.repo}`);
console.log(`Repository URL: ${context.payload.repository.html_url}`);
console.log(`Repository Full Name: ${context.payload.repository.full_name}`);
console.log(`Repository Name: ${context.payload.repository.name}`);
console.log(`Repository Owner: ${context.payload.repository.owner.login}`);
console.log(`Repository Owner URL: ${context.payload.repository.owner.html_url}`);
console.log(`Event Name: ${context.eventName}`);
const commentAuthor = context.payload.comment.user.login;
core.setOutput('comment_author', commentAuthor);
const isGreetingFromOwner = commentAuthor === context.payload.repository.owner.login;
core.setOutput('is_greeting_from_owner', isGreetingFromOwner.toString());
const isAlreadyAssigned = context.payload.issue.assignees.length > 0;
core.setOutput('is_already_assigned', isAlreadyAssigned.toString());
if (isCommandPresent && isGreetingFromOwner) {
console.log('Skipping assigning issue: Greeting from repository owner.');
console.log(`::set-output name=assign_issue::false`);
} else if (isCommandPresent && isAlreadyAssigned) {
const { owner, repo, number } = context.issue;
const assignees = context.payload.issue.assignees.map(assignee => assignee.login).join(', ');
const commentBody = `Hey @${commentAuthor} ! , This issue is already assigned to @${assignees}. 💗 \n You can work on other issues 🚀 \n If there is anything wrong you can contact us on [Discord🕹️](https://discord.gg/fgwk4XZfxG)👀`;
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody });
console.log(`Commented on the issue: ${commentBody}.`);
console.log(`::set-output name=assign_issue::false`);
} else if (isCommandPresent) {
console.log(`::set-output name=assign_issue::true`);
} else {
console.log(`::set-output name=assign_issue::false`);
}
- name: Assign the issue
if: steps.check_command.outputs.assign_issue == 'true'
id: assign_issue
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const { owner, repo, number } = context.issue;
const assignee = context.payload.comment.user.login;
await github.issues.addAssignees({ owner, repo, issue_number: number, assignees: [assignee] });
console.log(`Assigned the issue to ${assignee}.`);
59 changes: 59 additions & 0 deletions .github/workflows/close_invalid_issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Close Issues Without Keywords
on:
issues:
types:
- opened

jobs:
close-issue:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Close issue without keywords
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const keywords = ['Documentation Bug', 'New game', 'Enhancement', 'Bug', 'Question'];
const issueTitle = context.payload.issue.title ? context.payload.issue.title.toLowerCase() : '';
const openerUsername = context.payload.issue.user.login;
let containsKeyword = false;
for (const keyword of keywords) {
if (issueTitle.includes(keyword.toLowerCase())) {
containsKeyword = true;
break;
}
}
if (!containsKeyword) {
const commentBody = `Hey @${openerUsername}! 🙂 \n It seems like you are not following proper guidelines !! 👀 \n Read documentation properly !!🙏 \n If you have any queries reach out to us on [Discord](https://discord.gg/rZb46cCMmK) .`;
// Close the issue
await github.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
state: 'closed'
});
// Add comment to the issue
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
console.log('Closed the issue and added a comment.');
} else {
console.log('Issue contains one of the keywords. Skipping...');
}
80 changes: 80 additions & 0 deletions .github/workflows/close_old_issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Close Older Issues

on:
workflow_dispatch:

jobs:
close-older-issues:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Install dependencies
run: npm install @actions/github

- name: Fetch opened issues
id: fetch_issues
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const oneWeekAgo = new Date();
oneWeekAgo.setDate(oneWeekAgo.getDate() - 7);
const { data: issues } = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
sort: 'created',
direction: 'asc',
per_page: 100
});
const olderIssues = issues.filter(issue => issue.pull_request === undefined && new Date(issue.created_at) < oneWeekAgo);
core.setOutput('older_issues', olderIssues.map(issue => issue.number).join(','));
- name: Close older issues and comment
if: steps.fetch_issues.outputs.older_issues != ''
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const olderIssueNumbers = '${{ steps.fetch_issues.outputs.older_issues }}'.split(',');
for (const issueNumber of olderIssueNumbers) {
// Get the issue details
const { data: issue } = await github.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issueNumber)
});
// Close the older issue
await github.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issueNumber),
state: 'closed'
});
// Comment on the closed issue
await github.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: parseInt(issueNumber),
body: `Hello @${issue.user.login}, Time's up!⏰ \n Sorry for closing your issue! \n But it's more than a week since we haven't received anything from your side 😢 . \n Come up with new ideas, create a new issue and make sure you finish it within a week! 🔥 \n All the best! 🚀 \n Happy Hacking! 💗`
});
console.log(`Closed and commented on issue #${issueNumber}.`);
}
- name: Skip if no older issues
if: steps.fetch_issues.outputs.older_issues == ''
run: echo "No older issues found. Skipping..."
125 changes: 125 additions & 0 deletions .github/workflows/greet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
name: Comment and Label on Issue Opened
on:
issues:
types:
- opened

jobs:
comment_and_label:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Add comment
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const commentAuthor = context.payload.issue.user.login;
const commentBody = `Hey @${commentAuthor} ! \n Thank you for raising an issue 💗 \n You can self assign the issue by commenting /assign in comment 😀 \n Make sure you follow [CODE OF CONDUCT](https://github.com/GameSphere-MultiPlayer/GameSphere/blob/main/.github/CODE_OF_CONDUCT.md) `;
const { owner, repo, number } = context.issue;
await github.issues.createComment({
owner: owner,
repo: repo,
issue_number: number,
body: commentBody
});
- name: Add label if issue body contains "GSSoC24"
id: check_label_gs_soc24
run: |
if grep -qE "GSSoC24" <<< "${{ github.event.issue.body }}"; then
echo "::set-output name=add_label_gs_soc24::true"
else
echo "::set-output name=add_label_gs_soc24::false"
fi
- name: Add label "GSSoC24"
if: ${{ steps.check_label_gs_soc24.outputs.add_label_gs_soc24 == 'true' }}
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const { owner, repo, number } = context.issue;
await github.issues.addLabels({
owner: owner,
repo: repo,
issue_number: number,
labels: ["gssoc"]
});
- name: Add label if issue body contains "GSSoC23"
id: check_label_gs_soc23
run: |
if grep -qE "GSSoC23" <<< "${{ github.event.issue.body }}"; then
echo "::set-output name=add_label_gs_soc23::true"
else
echo "::set-output name=add_label_gs_soc23::false"
fi
- name: Add label "GSSoC23"
if: ${{ steps.check_label_gs_soc23.outputs.add_label_gs_soc23 == 'true' }}
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const { owner, repo, number } = context.issue;
await github.issues.addLabels({
owner: owner,
repo: repo,
issue_number: number,
labels: ["GSSoC23"]
});
- name: Add label if issue body contains "hacktoberfest"
id: check_label_hacktoberfest
run: |
if grep -qE "hacktoberfest" <<< "${{ github.event.issue.body }}"; then
echo "::set-output name=add_label_hacktoberfest::true"
else
echo "::set-output name=add_label_hacktoberfest::false"
fi
- name: Add label "hacktoberfest"
if: ${{ steps.check_label_hacktoberfest.outputs.add_label_hacktoberfest == 'true' }}
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const { owner, repo, number } = context.issue;
await github.issues.addLabels({
owner: owner,
repo: repo,
issue_number: number,
labels: ["hacktoberfest"]
});
- name: Add label if issue body contains "IWOC2024"
id: check_label_iwoc
run: |
if grep -qE "IWOC2024" <<< "${{ github.event.issue.body }}"; then
echo "::set-output name=add_label_iwoc::true"
else
echo "::set-output name=add_label_iwoc::false"
fi
- name: Add label "IWOC2024"
if: ${{ steps.check_label_iwoc.outputs.add_label_iwoc == 'true' }}
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const { owner, repo, number } = context.issue;
await github.issues.addLabels({
owner: owner,
repo: repo,
issue_number: number,
labels: ["IWOC2024"]
});
22 changes: 22 additions & 0 deletions .github/workflows/issue_close_greet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Comment on Issue Closure
on:
issues:
types:
- closed

jobs:
comment:
runs-on: ubuntu-latest

steps:
- name: Comment on Issue Closure
uses: actions/github-script@v4
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
script: |
const { owner, repo, number } = context.issue;
const author = context.payload.issue.user.login;
const commentBody = `Hey @${author} ! Thank you so much for your raising the issue💗 \n It’s all yours, you can come anytime again and make some contributions! 🚀 \n Alone, we can do little, but together we can do so much! 😇
`;
await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody });
console.log(`Commented on the issue: ${commentBody}.`);
Loading

0 comments on commit cd83912

Please sign in to comment.