diff --git a/.github/workflows/close_old_issues.yml b/.github/workflows/close_old_issues.yml new file mode 100644 index 0000000..2b519dc --- /dev/null +++ b/.github/workflows/close_old_issues.yml @@ -0,0 +1,30 @@ +--- + name: Close Old Issues + on: + schedule: + - cron: 0 0 * * * + jobs: + close-issues: + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Close Old Issues + run: > + open_issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" + \ + "https://api.github.com/repos/${{ github.repository }}/issues?state=open" \ + | jq -r '.[] | .number') + for issue in $open_issues; do + # Get the last updated timestamp of the issue + last_updated=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + "https://api.github.com/repos/${{ github.repository }}/issues/$issue" \ + | jq -r '.updated_at') + days_since_update=$(( ( $(date +%s) - $(date -d "$last_updated" +%s) ) / 86400 )) + if [ $days_since_update -gt 20 ]; then # Modify the condition to check if days_since_update is greater than 20 + curl -s -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -d '{"state":"closed"}' \ + "https://api.github.com/repos/${{ github.repository }}/issues/$issue" + fi + done \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000..cee44ff --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,77 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ "main" ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '43 3 * * 6' + +jobs: + analyze: + name: Analyze + runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} + timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby', 'swift' ] + # Use only 'java' to analyze code written in Java, Kotlin or both + # Use only 'javascript' to analyze code written in JavaScript, TypeScript or both + # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v2 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + + # For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs + # queries: security-extended,security-and-quality + + + # Autobuild attempts to build any compiled languages (C/C++, C#, Go, Java, or Swift). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v2 + + # ℹ️ Command-line programs to run using the OS shell. + # πŸ“š See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # If the Autobuild fails above, remove it and uncomment the following three lines. + # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. + + # - run: | + # echo "Run, Build Application using script" + # ./location_of_script_within_repo/buildscript.sh + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v2 + with: + category: "/language:${{matrix.language}}" \ No newline at end of file diff --git a/.github/workflows/issue_close_greet.yml b/.github/workflows/issue_close_greet.yml new file mode 100644 index 0000000..c333d2f --- /dev/null +++ b/.github/workflows/issue_close_greet.yml @@ -0,0 +1,26 @@ +--- + 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}.`); \ No newline at end of file diff --git a/.github/workflows/issues.yml b/.github/workflows/issues.yml new file mode 100644 index 0000000..a130889 --- /dev/null +++ b/.github/workflows/issues.yml @@ -0,0 +1,37 @@ +--- + name: Add Comment to Newly Open Issue + on: + issues: + types: + - opened + jobs: + add-comment: + runs-on: ubuntu-latest + permissions: + issues: write + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Add Comment + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: > + const { issue } = context.payload; + + const author = issue.user.login; + + const issueNumber = issue.number; + + const comment = `Hello @${author}! \n Thank you for raising this issue. \nPlease make sure to follow our [Contributing Guidelines.](https://github.com/Eduhub-Community/Eduhub-Community.github.io/blob/main/contributors.html) \nDon't forget to ⭐ our [Edhub-Community.github.io .](https://github.com/Eduhub-Community/Eduhub-Community.github.io)\n\nOur review team will carefully assess the issue and reach out to you soon!\n We appreciate your patience!`; + + const { owner, repo } = context.repo; + + await github.issues.createComment({ + owner: owner, + repo: repo, + issue_number: issueNumber, + body: comment + }); + + console.log(`Comment added to the Issue #${issueNumber}.`); diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml new file mode 100644 index 0000000..56c9330 --- /dev/null +++ b/.github/workflows/lock.yml @@ -0,0 +1,23 @@ +--- + name: Lock new issues + on: + issues: + types: opened + permissions: + issues: write + jobs: + action: + runs-on: ubuntu-latest + steps: + - name: Lock issues + uses: dessant/repo-lockdown@v3 + with: + close-issue: false + exclude-issue-labels: gssoc23. + process-only: issues + skip-closed-issue-comment: true + issue-comment: > + To reduce notifications, issues are locked. Your issue will be + unlocked when we add the label `gssoc23`. If you're participating in + GSSoC'23, please add the `gssoc23` label to your issue. + \ No newline at end of file diff --git a/.github/workflows/pr_close_greet.yml b/.github/workflows/pr_close_greet.yml new file mode 100644 index 0000000..f6cfa99 --- /dev/null +++ b/.github/workflows/pr_close_greet.yml @@ -0,0 +1,26 @@ +--- + name: Comment on PR Closure + on: + pull_request_target: + types: + - closed + jobs: + comment: + runs-on: ubuntu-latest + steps: + - name: Comment on PR Closure + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + script: > + const { owner, repo, number } = context.issue; + + const commentAuthor = context.payload.pull_request.user.login; + + const commentBody = `Thank you @${commentAuthor} , for your valuable time and contribution in our `Eduhub-Community`. \n \n Hoping to see you soon with another PR again πŸ˜‡ \n Wishing you all the best for your journey into Open SourceπŸš€ + + `; + + await github.issues.createComment({ owner, repo, issue_number: number, body: commentBody }); + + console.log(`Commented on the closed PR: ${commentBody}.`); diff --git a/.github/workflows/prevent_multiple_issues.yml b/.github/workflows/prevent_multiple_issues.yml new file mode 100644 index 0000000..6d59674 --- /dev/null +++ b/.github/workflows/prevent_multiple_issues.yml @@ -0,0 +1,69 @@ +name: Close Issue if Opener has Opened Issues + +on: + issues: + types: + - opened + +jobs: + close_issue: + runs-on: ubuntu-latest + + steps: + - name: Check if opener has multiple open issues + id: check_open_issues + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + const issueNumber = context.issue.number; + const issueOpener = context.payload.issue.user.login; + const previousIssuesResponse = await github.request('GET /repos/{owner}/{repo}/issues', { + owner, + repo, + state: 'open', + creator: issueOpener + }); + const previousOpenIssues = previousIssuesResponse.data.filter(issue => issue.number !== issueNumber && !issue.pull_request); + const previousOpenIssueNumbers = previousOpenIssues.map(issue => `#${issue.number}`); + const openerName = context.payload.issue.user.login; + const closeIssue = previousOpenIssues.length > 0; + console.log(`Close issue: ${closeIssue}`); + if (closeIssue) { + const comment = `Hey @${openerName} , You can't have another issue before completing the previous one πŸ˜€ \n you already have the following ${previousOpenIssues.length} open issues πŸ‘€ ! :\n\n${previousOpenIssueNumbers.join('\n')}`; + core.exportVariable('comment_body', comment); // Export the variable + core.setOutput('close_issue', true); + } else { + core.exportVariable('comment_body', ''); + core.setOutput('close_issue', false); + } + - name: Close the issue and add a comment + if: always() && ${{ needs.check_open_issues.outputs.close_issue }} + uses: actions/github-script@v4 + with: + github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + script: | + const owner = context.repo.owner; + const repo = context.repo.repo; + const issueNumber = context.issue.number; + const comment = process.env.comment_body; // Retrieve the exported variable + + if (comment.trim() === '') { + console.log('Comment body is empty. Skipping comment creation.'); + return; + } + const closeComment = `${comment}`; + await github.issues.createComment({ + owner, + repo, + issue_number: issueNumber, + body: closeComment + }); + await github.issues.update({ + owner, + repo, + issue_number: issueNumber, + state: 'closed' + }); \ No newline at end of file