diff --git a/.github/workflows/contributors.yml b/.github/workflows/contributors.yml new file mode 100644 index 0000000..b896fed --- /dev/null +++ b/.github/workflows/contributors.yml @@ -0,0 +1,60 @@ +name: Contributors + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + contributors: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Generate contributors list + uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const contributors = await github.rest.repos.listContributors({ + owner: context.repo.owner, + repo: context.repo.repo + }); + + const contributorsList = contributors.data + .filter(contributor => contributor.contributions > 0) + .map(contributor => ` + + ${contributor.login} + `).join('\n'); + + const fs = require('fs'); + const readmePath = './README.md'; + let readmeContent = fs.readFileSync(readmePath, 'utf8'); + + const contributorsSection = ` +## 👥 Contribuidores + +Um agradecimento especial a todos que contribuíram para este projeto: + +
+${contributorsList} +
+`; + + readmeContent = readmeContent.replace(/## 👥 Contribuidores[\s\S]*?(?=## 📘 Licença)/, contributorsSection); + + fs.writeFileSync(readmePath, readmeContent); + + - name: Commit changes + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add README.md + git commit -m "Update contributors list" || exit 0 + git push \ No newline at end of file diff --git a/README.MD b/README.MD index 2e5c98b..16a4f9a 100644 --- a/README.MD +++ b/README.MD @@ -40,6 +40,17 @@ Toda ajuda é bem-vinda! Para colaborar, siga esses passos: Dê uma olhada no arquivo [CONTRIBUTING.md](./CONTRIBUTING.md) para mais detalhes. + +--- + +## 👥 Contribuidores + +Um agradecimento especial a todos que contribuíram para este projeto: + +
+ +
+ ---