diff --git a/.github/workflows/auto-comment-on-pr-merge.yml b/.github/workflows/auto-comment-on-pr-merge.yml index c9a9f420..58f6b3c8 100644 --- a/.github/workflows/auto-comment-on-pr-merge.yml +++ b/.github/workflows/auto-comment-on-pr-merge.yml @@ -1,3 +1,5 @@ +# @format + name: Auto Comment on PR Merge on: @@ -10,11 +12,11 @@ jobs: runs-on: ubuntu-latest steps: - - name: Add Comment to Merged PR - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - curl -H "Authorization: token $GITHUB_TOKEN" \ - -X POST \ - -d '{"body":"🎉 Your pull request has been successfully merged! 🎉 Thank you for your contribution to our project. Your efforts are greatly appreciated. Keep up the fantastic work! 🚀"}' \ - "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" + - name: Add Comment to Merged PR + env: + TOKEN: ${{ secrets.TOKEN }} + run: | + curl -H "Authorization: token $TOKEN" \ + -X POST \ + -d '{"body":"🎉 Your pull request has been successfully merged! 🎉 Thank you for your contribution to our project. Your efforts are greatly appreciated. Keep up the fantastic work! 🚀"}' \ + "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" diff --git a/.github/workflows/check_duplicate_tools.yml b/.github/workflows/check_duplicate_tools.yml index 5fe6a2b1..a627277e 100644 --- a/.github/workflows/check_duplicate_tools.yml +++ b/.github/workflows/check_duplicate_tools.yml @@ -1,3 +1,5 @@ +# @format + name: Check for Duplicates and Close Issues on PR Merge on: @@ -8,20 +10,20 @@ jobs: check-duplicates: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v2 - - name: Check for duplicate entries in product.json - run: | - # Check for duplicate entries based on the 'link' field in product.json - jq -r '.[].link' product.json | sort | uniq -d > duplicates.txt - if [ -s duplicates.txt ]; then - echo "Duplicate entries found in product.json based on 'link':" - cat duplicates.txt - exit 1 - else - echo "No duplicate entries found based on 'link'." - fi + - name: Check for duplicate entries in product.json + run: | + # Check for duplicate entries based on the 'link' field in product.json + jq -r '.[].link' product.json | sort | uniq -d > duplicates.txt + if [ -s duplicates.txt ]; then + echo "Duplicate entries found in product.json based on 'link':" + cat duplicates.txt + exit 1 + else + echo "No duplicate entries found based on 'link'." + fi close-issues: runs-on: ubuntu-latest @@ -29,21 +31,21 @@ jobs: if: github.event.pull_request.merged == true steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v2 - - name: Close linked issues - run: | - ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#') - for ISSUE in $ISSUES - do - echo "Closing issue #$ISSUE" - curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE/comments \ - -d '{"body":"Closed by PR #${{ github.event.pull_request.number }}"}' - curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE \ - -d '{"state":"closed"}' - done \ No newline at end of file + - name: Close linked issues + run: | + ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#') + for ISSUE in $ISSUES + do + echo "Closing issue #$ISSUE" + curl -X POST -H "Authorization: token ${{ secrets.TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE/comments \ + -d '{"body":"Closed by PR #${{ github.event.pull_request.number }}"}' + curl -X PATCH -H "Authorization: token ${{ secrets.TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE \ + -d '{"state":"closed"}' + done diff --git a/.github/workflows/close-old-pr-woc.yml b/.github/workflows/close-old-pr-woc.yml index 32367c5e..990c8564 100644 --- a/.github/workflows/close-old-pr-woc.yml +++ b/.github/workflows/close-old-pr-woc.yml @@ -1,3 +1,5 @@ +# @format + name: Close Stale PRs on: @@ -18,17 +20,17 @@ jobs: runs-on: ubuntu-latest permissions: pull-requests: write - + steps: - - uses: actions/stale@v7 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-pr-message: 'This PR has been automatically closed due to inactivity from the owner for 15 days.' - days-before-pr-stale: 15 - days-before-pr-close: 0 - exempt-pr-author: false - exempt-pr-labels: '' - only-labels: '' - operations-per-run: 30 - remove-stale-when-updated: true - debug-only: false \ No newline at end of file + - uses: actions/stale@v7 + with: + repo-token: ${{ secrets.TOKEN }} + stale-pr-message: 'This PR has been automatically closed due to inactivity from the owner for 15 days.' + days-before-pr-stale: 15 + days-before-pr-close: 0 + exempt-pr-author: false + exempt-pr-labels: '' + only-labels: '' + operations-per-run: 30 + remove-stale-when-updated: true + debug-only: false diff --git a/.github/workflows/close-on-merge.yml b/.github/workflows/close-on-merge.yml index 9a7edc28..9abdfd2c 100644 --- a/.github/workflows/close-on-merge.yml +++ b/.github/workflows/close-on-merge.yml @@ -1,3 +1,5 @@ +# @format + name: Close Issues on PR Merge on: @@ -9,22 +11,22 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 + - name: Checkout repository + uses: actions/checkout@v2 - - name: Close linked issues - if: github.event.pull_request.merged == true - run: | - ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#') - for ISSUE in $ISSUES - do - echo "Closing issue #$ISSUE" - curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE/comments \ - -d '{"body":"Closed by PR #${{ github.event.pull_request.number }}"}' - curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ - -H "Accept: application/vnd.github.v3+json" \ - https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE \ - -d '{"state":"closed"}' - done \ No newline at end of file + - name: Close linked issues + if: github.event.pull_request.merged == true + run: | + ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#') + for ISSUE in $ISSUES + do + echo "Closing issue #$ISSUE" + curl -X POST -H "Authorization: token ${{ secrets.TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE/comments \ + -d '{"body":"Closed by PR #${{ github.event.pull_request.number }}"}' + curl -X PATCH -H "Authorization: token ${{ secrets.TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE \ + -d '{"state":"closed"}' + done diff --git a/.github/workflows/greetings.yaml b/.github/workflows/greetings.yaml index 704db0e2..eb68a241 100644 --- a/.github/workflows/greetings.yaml +++ b/.github/workflows/greetings.yaml @@ -1,3 +1,5 @@ +# @format + name: Greetings on: [pull_request_target, issues] @@ -9,8 +11,8 @@ jobs: issues: write pull-requests: write steps: - - uses: actions/first-interaction@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - issue-message: "Hi there! Thanks for opening this issue. We appreciate your contribution to this open-source project. We aim to respond or assign your issue as soon as possible." - pr-message: "Welcome to Our repository.🎊 Thank you so much for taking the time to point this out." + - uses: actions/first-interaction@v1 + with: + repo-token: ${{ secrets.TOKEN }} + issue-message: 'Hi there! Thanks for opening this issue. We appreciate your contribution to this open-source project. We aim to respond or assign your issue as soon as possible.' + pr-message: 'Welcome to Our repository.🎊 Thank you so much for taking the time to point this out.' diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index ec049324..5d8c4100 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -1,3 +1,5 @@ +# @format + name: 'Greetings' on: @@ -16,9 +18,9 @@ jobs: - uses: actions/checkout@v1 - uses: EddieHubCommunity/gh-action-community/src/welcome@main with: - github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.TOKEN }} issue-message: | Congratulations, @${{ github.actor }}! 🎉 Thank you for creating your issue. Your contribution is greatly appreciated and we look forward to working with you to resolve the issue. Keep up the great work! pr-message: | Great job, @${{ github.actor }}! 🎉 Thank you for submitting your pull request. Your contribution is valuable and we appreciate your efforts to improve our project. - footer: 'We will promptly review your changes and offer feedback. Keep up the excellent work! Kindly remember to check our [contributing guidelines](https://github.com/HimanshuNarware/Devlabs/blob/main/CONTRIBUTING.md)' \ No newline at end of file + footer: 'We will promptly review your changes and offer feedback. Keep up the excellent work! Kindly remember to check our [contributing guidelines](https://github.com/HimanshuNarware/Devlabs/blob/main/CONTRIBUTING.md)' diff --git a/.github/workflows/restrict_pr.yml b/.github/workflows/restrict_pr.yml deleted file mode 100644 index e13f8a6c..00000000 --- a/.github/workflows/restrict_pr.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: Restrict Contributor to limited contributions in Devlabs - -on: - pull_request_target: - types: - - opened - -jobs: - evaluate_and_close: - runs-on: ubuntu-latest - - steps: - - name: Check merged pull requests and calculate score - id: calculate_score - uses: actions/github-script@v4 - with: - github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - script: | - const owner = context.repo.owner; - const repo = context.repo.repo; - const pullRequestOpener = context.payload.pull_request.user.login; - - let mergedPullRequests = []; - let page = 1; - let perPage = 100; - let response; - - do { - response = await github.pulls.list({ - owner, - repo, - state: 'closed', - per_page: perPage, - page: page - }); - - mergedPullRequests = mergedPullRequests.concat(response.data.filter(pr => pr.user.login === pullRequestOpener && pr.merged_at !== null)); - page++; - } while (response.data.length === perPage); - - let score = 0; - let prDetails = []; - const scoreMap = { - 'level3': 45, - 'level2': 25, - 'level1': 10 - }; - - for (const pr of mergedPullRequests) { - let prScore = 0; - let labelsWithScores = []; - for (const label of pr.labels) { - if (scoreMap[label.name]) { - prScore += scoreMap[label.name]; - labelsWithScores.push(`${label.name} score: (${scoreMap[label.name]})`); - } - } - score += prScore; - if (labelsWithScores.length > 0) { - prDetails.push(`- [#${pr.number}](${pr.html_url}) with labels: ${labelsWithScores.join(', ')}`); - } - } - - const threshold = 150; - - console.log(`User score: ${score}`); - console.log(`Score threshold: ${threshold}`); - - if (score >= threshold) { - const comment = `Hey @${pullRequestOpener}, You have reached your limit to contribute in Devlabs with a score of ${score}. \n We believe in giving equal opportunity to everyone so you will not be able to contribute to Devlabs now onwards. 💗 \n Thank you for your valuable time and contribution in Devlabs 🕹️! \n\n Your merged pull requests:\n${prDetails.join('\n')}`; - core.exportVariable('comment_body', comment); - core.setOutput('close_pull_request', true); - } else { - core.exportVariable('comment_body', ''); - core.setOutput('close_pull_request', false); - } - - - name: Add spam label and close the pull request - if: always() && steps.calculate_score.outputs.close_pull_request == 'true' - uses: actions/github-script@v4 - with: - github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - script: | - const owner = context.repo.owner; - const repo = context.repo.repo; - const pullRequestNumber = context.payload.pull_request.number; - const comment = process.env.comment_body; - - if (comment.trim() === '') { - console.log('Comment body is empty. Skipping comment creation.'); - return; - } - - await github.issues.createComment({ - owner, - repo, - issue_number: pullRequestNumber, - body: comment - }); - - await github.issues.addLabels({ - owner, - repo, - issue_number: pullRequestNumber, - labels: ['spam🚨'] - }); - - await github.pulls.update({ - owner, - repo, - pull_number: pullRequestNumber, - state: 'closed' - }); \ No newline at end of file