Criação de Arquivo de Contribuição #28
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: Agendamento de Evento | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
agendar-evento: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
issues: write | |
env: | |
ISSUE_BODY: "${{ github.event.issue.body }}" | |
if: contains(github.event.issue.title, '[Evento]:') | |
steps: | |
- name: Agendar Evento | |
uses: actions/checkout@v3 | |
- name: Issue Forms Body Parser | |
id: parse | |
uses: zentered/issue-forms-body-parser@v2.1.1 | |
with: | |
body: ${{ env.ISSUE_BODY }} | |
- name: transformar dados | |
id: tratamento | |
run: | | |
evento=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq .evento.text | sed 's/"//g') | |
site=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq .site.text | sed 's/"//g') | |
tipo=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq .tipo.text | sed 's/"//g') | |
local=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq .local.text | sed 's/"//g') | |
mes=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq .mes.text | sed 's/"//g') | |
dia=$(echo ${{ toJSON(steps.parse.outputs.data) }} | jq .dia.text | sed 's/"//g') | |
echo "evento=$evento" >> $GITHUB_OUTPUT | |
echo "site=$site" >> $GITHUB_OUTPUT | |
echo "tipo=$tipo" >> $GITHUB_OUTPUT | |
echo "local=$local" >> $GITHUB_OUTPUT | |
echo "mes=$mes" >> $GITHUB_OUTPUT | |
echo "dia=$dia" >> $GITHUB_OUTPUT | |
- name: Atualizar README.md | |
run: | | |
linha=$(cat README.md | grep -n "${{ steps.tratamento.outputs.mes }}:END" | cut -d: -f1) | |
if [ "${{ steps.tratamento.outputs.tipo }}" == "Presencial" ]; then | |
shield="![presencial](https://img.shields.io/static/v1?label=&message=presencial&color=darkblue)" | |
elif [ "${{ steps.tratamento.outputs.tipo }}" == "Online" ]; then | |
shield="![online](https://img.shields.io/static/v1?label=&message=online&color=green)" | |
elif [ "${{ steps.tratamento.outputs.tipo }}" == "Hibrido" ]; then | |
shield="![híbrido](https://img.shields.io/static/v1?label=&message=h%C3%ADbrido&color=blue)" | |
fi | |
dadosevento="- ${{ steps.tratamento.outputs.dia }} - [${{ steps.tratamento.outputs.evento }}](${{ steps.tratamento.outputs.site }}) - ${{ steps.tratamento.outputs.local }} - $shield" | |
echo "$dadosevento" | |
sed -i "${linha}i $dadosevento" README.md | |
- name: Commit changes | |
uses: stefanzweifel/git-auto-commit-action@v4 | |
with: | |
commit_message: "Atualizando README.md" | |
commit_options: '--no-verify' | |
commit_user_name: events-bot | |
commit_user_email: events@bot.com | |
- name: Create comment | |
uses: peter-evans/create-or-update-comment@v2 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
Evento cadastrado com sucesso!! | |
Obrigado por contribuir com a comunidade! | |
- name: Close Issue | |
uses: peter-evans/close-issue@v2 | |
with: | |
issue-number: ${{ github.event.issue.number }} |