docs: contribuidores adicionados no readme.md #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 => ` | ||
<a href="https://github.com/${contributor.login}" target="_blank"> | ||
<img src="https://github.com/${contributor.login}.png" width="100" height="100" alt="${contributor.login}"> | ||
</a>`).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: | ||
<div style="display: flex; flex-wrap: wrap; gap: 10px;"> | ||
${contributorsList} | ||
</div> | ||
`; | ||
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 |