From 1677a11d4ede7e7d4f9b8b190e15967343f4d86a Mon Sep 17 00:00:00 2001 From: Himanshu Narware Date: Wed, 4 Sep 2024 14:44:47 +0530 Subject: [PATCH 1/3] comment the workflow --- .../workflows/auto-comment-on-pr-merge.yml | 34 +-- .github/workflows/check_duplicate_tools.yml | 86 +++---- .github/workflows/close-old-pr-woc.yml | 60 ++--- .github/workflows/close-on-merge.yml | 52 ++-- .github/workflows/greetings.yaml | 28 +-- .github/workflows/greetings.yml | 44 ++-- .github/workflows/restrict_pr.yml | 226 +++++++++--------- 7 files changed, 265 insertions(+), 265 deletions(-) diff --git a/.github/workflows/auto-comment-on-pr-merge.yml b/.github/workflows/auto-comment-on-pr-merge.yml index c9a9f420..7068fbb5 100644 --- a/.github/workflows/auto-comment-on-pr-merge.yml +++ b/.github/workflows/auto-comment-on-pr-merge.yml @@ -1,20 +1,20 @@ -name: Auto Comment on PR Merge +# name: Auto Comment on PR Merge -on: - pull_request: - types: [closed] +# on: +# pull_request: +# types: [closed] -jobs: - comment: - if: github.event.pull_request.merged == true - runs-on: ubuntu-latest +# jobs: +# comment: +# if: github.event.pull_request.merged == true +# 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" +# 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" diff --git a/.github/workflows/check_duplicate_tools.yml b/.github/workflows/check_duplicate_tools.yml index 5fe6a2b1..5a041e1d 100644 --- a/.github/workflows/check_duplicate_tools.yml +++ b/.github/workflows/check_duplicate_tools.yml @@ -1,49 +1,49 @@ -name: Check for Duplicates and Close Issues on PR Merge +# name: Check for Duplicates and Close Issues on PR Merge -on: - pull_request: - types: [opened, synchronize, closed] +# on: +# pull_request: +# types: [opened, synchronize, closed] -jobs: - check-duplicates: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 +# jobs: +# check-duplicates: +# runs-on: ubuntu-latest +# steps: +# - 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 - needs: check-duplicates - if: github.event.pull_request.merged == true +# close-issues: +# runs-on: ubuntu-latest +# needs: check-duplicates +# if: github.event.pull_request.merged == true - steps: - - name: Checkout repository - uses: actions/checkout@v2 +# steps: +# - 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.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 diff --git a/.github/workflows/close-old-pr-woc.yml b/.github/workflows/close-old-pr-woc.yml index 32367c5e..5b9f9c20 100644 --- a/.github/workflows/close-old-pr-woc.yml +++ b/.github/workflows/close-old-pr-woc.yml @@ -1,34 +1,34 @@ -name: Close Stale PRs +# name: Close Stale PRs -on: - schedule: - - cron: '0 0 * * *' # Runs daily at midnight - pull_request: - types: - - opened - - reopened - - synchronize +# on: +# schedule: +# - cron: '0 0 * * *' # Runs daily at midnight +# pull_request: +# types: +# - opened +# - reopened +# - synchronize -permissions: - pull-requests: write - issues: write +# permissions: +# pull-requests: write +# issues: write -jobs: - close_stale_prs: - runs-on: ubuntu-latest - permissions: - pull-requests: write +# jobs: +# close_stale_prs: +# 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 +# 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 diff --git a/.github/workflows/close-on-merge.yml b/.github/workflows/close-on-merge.yml index 9a7edc28..c08e4aab 100644 --- a/.github/workflows/close-on-merge.yml +++ b/.github/workflows/close-on-merge.yml @@ -1,30 +1,30 @@ -name: Close Issues on PR Merge +# name: Close Issues on PR Merge -on: - pull_request: - types: [closed] +# on: +# pull_request: +# types: [closed] -jobs: - close-issues: - runs-on: ubuntu-latest +# # jobs: +# close-issues: +# runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@v2 +# steps: +# - 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.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 diff --git a/.github/workflows/greetings.yaml b/.github/workflows/greetings.yaml index 704db0e2..c1dfed21 100644 --- a/.github/workflows/greetings.yaml +++ b/.github/workflows/greetings.yaml @@ -1,16 +1,16 @@ -name: Greetings +# name: Greetings -on: [pull_request_target, issues] +# on: [pull_request_target, issues] -jobs: - greeting: - runs-on: ubuntu-latest - permissions: - 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." +# jobs: +# greeting: +# runs-on: ubuntu-latest +# permissions: +# 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." diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index ec049324..6459e3c6 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -1,24 +1,24 @@ -name: 'Greetings' +# name: 'Greetings' -on: - fork: - push: - branches: [main] - issues: - types: [opened] - pull_request_target: - types: [opened] +# on: +# fork: +# push: +# branches: [main] +# issues: +# types: [opened] +# pull_request_target: +# types: [opened] -jobs: - welcome: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: EddieHubCommunity/gh-action-community/src/welcome@main - with: - github-token: ${{ secrets.GITHUB_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 +# jobs: +# welcome: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v1 +# - uses: EddieHubCommunity/gh-action-community/src/welcome@main +# with: +# github-token: ${{ secrets.GITHUB_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 diff --git a/.github/workflows/restrict_pr.yml b/.github/workflows/restrict_pr.yml index e13f8a6c..5c143634 100644 --- a/.github/workflows/restrict_pr.yml +++ b/.github/workflows/restrict_pr.yml @@ -1,113 +1,113 @@ -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 +# 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 From b9670b5e41f4781d60fbb5334e1b67964748f789 Mon Sep 17 00:00:00 2001 From: Himanshu Narware Date: Wed, 4 Sep 2024 15:04:26 +0530 Subject: [PATCH 2/3] test --- .../workflows/auto-comment-on-pr-merge.yml | 34 +-- .github/workflows/check_duplicate_tools.yml | 86 +++---- .github/workflows/close-old-pr-woc.yml | 60 ++--- .github/workflows/close-on-merge.yml | 52 ++-- .github/workflows/greetings.yaml | 28 +-- .github/workflows/greetings.yml | 44 ++-- .github/workflows/restrict_pr.yml | 226 +++++++++--------- 7 files changed, 265 insertions(+), 265 deletions(-) diff --git a/.github/workflows/auto-comment-on-pr-merge.yml b/.github/workflows/auto-comment-on-pr-merge.yml index 7068fbb5..c9a9f420 100644 --- a/.github/workflows/auto-comment-on-pr-merge.yml +++ b/.github/workflows/auto-comment-on-pr-merge.yml @@ -1,20 +1,20 @@ -# name: Auto Comment on PR Merge +name: Auto Comment on PR Merge -# on: -# pull_request: -# types: [closed] +on: + pull_request: + types: [closed] -# jobs: -# comment: -# if: github.event.pull_request.merged == true -# runs-on: ubuntu-latest +jobs: + comment: + if: github.event.pull_request.merged == true + 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" + 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" diff --git a/.github/workflows/check_duplicate_tools.yml b/.github/workflows/check_duplicate_tools.yml index 5a041e1d..5fe6a2b1 100644 --- a/.github/workflows/check_duplicate_tools.yml +++ b/.github/workflows/check_duplicate_tools.yml @@ -1,49 +1,49 @@ -# name: Check for Duplicates and Close Issues on PR Merge +name: Check for Duplicates and Close Issues on PR Merge -# on: -# pull_request: -# types: [opened, synchronize, closed] +on: + pull_request: + types: [opened, synchronize, closed] -# jobs: -# check-duplicates: -# runs-on: ubuntu-latest -# steps: -# - name: Checkout repository -# uses: actions/checkout@v2 +jobs: + check-duplicates: + runs-on: ubuntu-latest + steps: + - 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 -# needs: check-duplicates -# if: github.event.pull_request.merged == true + close-issues: + runs-on: ubuntu-latest + needs: check-duplicates + if: github.event.pull_request.merged == true -# steps: -# - name: Checkout repository -# uses: actions/checkout@v2 + steps: + - 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.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 diff --git a/.github/workflows/close-old-pr-woc.yml b/.github/workflows/close-old-pr-woc.yml index 5b9f9c20..32367c5e 100644 --- a/.github/workflows/close-old-pr-woc.yml +++ b/.github/workflows/close-old-pr-woc.yml @@ -1,34 +1,34 @@ -# name: Close Stale PRs +name: Close Stale PRs -# on: -# schedule: -# - cron: '0 0 * * *' # Runs daily at midnight -# pull_request: -# types: -# - opened -# - reopened -# - synchronize +on: + schedule: + - cron: '0 0 * * *' # Runs daily at midnight + pull_request: + types: + - opened + - reopened + - synchronize -# permissions: -# pull-requests: write -# issues: write +permissions: + pull-requests: write + issues: write -# jobs: -# close_stale_prs: -# runs-on: ubuntu-latest -# permissions: -# pull-requests: write +jobs: + close_stale_prs: + 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 + 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 diff --git a/.github/workflows/close-on-merge.yml b/.github/workflows/close-on-merge.yml index c08e4aab..9a7edc28 100644 --- a/.github/workflows/close-on-merge.yml +++ b/.github/workflows/close-on-merge.yml @@ -1,30 +1,30 @@ -# name: Close Issues on PR Merge +name: Close Issues on PR Merge -# on: -# pull_request: -# types: [closed] +on: + pull_request: + types: [closed] -# # jobs: -# close-issues: -# runs-on: ubuntu-latest +jobs: + close-issues: + runs-on: ubuntu-latest -# steps: -# - name: Checkout repository -# uses: actions/checkout@v2 + steps: + - 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.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 diff --git a/.github/workflows/greetings.yaml b/.github/workflows/greetings.yaml index c1dfed21..704db0e2 100644 --- a/.github/workflows/greetings.yaml +++ b/.github/workflows/greetings.yaml @@ -1,16 +1,16 @@ -# name: Greetings +name: Greetings -# on: [pull_request_target, issues] +on: [pull_request_target, issues] -# jobs: -# greeting: -# runs-on: ubuntu-latest -# permissions: -# 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." +jobs: + greeting: + runs-on: ubuntu-latest + permissions: + 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." diff --git a/.github/workflows/greetings.yml b/.github/workflows/greetings.yml index 6459e3c6..ec049324 100644 --- a/.github/workflows/greetings.yml +++ b/.github/workflows/greetings.yml @@ -1,24 +1,24 @@ -# name: 'Greetings' +name: 'Greetings' -# on: -# fork: -# push: -# branches: [main] -# issues: -# types: [opened] -# pull_request_target: -# types: [opened] +on: + fork: + push: + branches: [main] + issues: + types: [opened] + pull_request_target: + types: [opened] -# jobs: -# welcome: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v1 -# - uses: EddieHubCommunity/gh-action-community/src/welcome@main -# with: -# github-token: ${{ secrets.GITHUB_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 +jobs: + welcome: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: EddieHubCommunity/gh-action-community/src/welcome@main + with: + github-token: ${{ secrets.GITHUB_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 diff --git a/.github/workflows/restrict_pr.yml b/.github/workflows/restrict_pr.yml index 5c143634..e13f8a6c 100644 --- a/.github/workflows/restrict_pr.yml +++ b/.github/workflows/restrict_pr.yml @@ -1,113 +1,113 @@ -# 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 +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 From 98cad44d4d54dd767614f19dbd8f415dde1da20e Mon Sep 17 00:00:00 2001 From: Himanshu Narware Date: Wed, 4 Sep 2024 15:24:52 +0530 Subject: [PATCH 3/3] testing workflow --- .../workflows/auto-comment-on-pr-merge.yml | 18 +++--- .github/workflows/check_duplicate_tools.yml | 62 ++++++++++--------- .github/workflows/close-old-pr-woc.yml | 28 +++++---- .github/workflows/close-on-merge.yml | 38 ++++++------ .github/workflows/greetings.yaml | 12 ++-- .github/workflows/greetings.yml | 6 +- .github/workflows/restrict_pr.yml | 8 ++- 7 files changed, 93 insertions(+), 79 deletions(-) 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 index e13f8a6c..fac4f322 100644 --- a/.github/workflows/restrict_pr.yml +++ b/.github/workflows/restrict_pr.yml @@ -1,3 +1,5 @@ +# @format + name: Restrict Contributor to limited contributions in Devlabs on: @@ -14,7 +16,7 @@ jobs: id: calculate_score uses: actions/github-script@v4 with: - github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + github-token: ${{ secrets.TOKEN }} script: | const owner = context.repo.owner; const repo = context.repo.repo; @@ -79,7 +81,7 @@ jobs: if: always() && steps.calculate_score.outputs.close_pull_request == 'true' uses: actions/github-script@v4 with: - github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} + github-token: ${{ secrets.TOKEN }} script: | const owner = context.repo.owner; const repo = context.repo.repo; @@ -110,4 +112,4 @@ jobs: repo, pull_number: pullRequestNumber, state: 'closed' - }); \ No newline at end of file + });