Agenda/Evento: maximizar eficiência e inovação na saúde com IA #5
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: Criar PR para Cancelar Evento/Agenda | |
on: | |
issues: | |
types: [opened] | |
permissions: | |
contents: write | |
pull-requests: write | |
issues: write | |
env: | |
reviewers: "pachicodes,stephan-lopes" | |
jobs: | |
delete-event: | |
if: contains(github.event.issue.labels.*.name, 'cancelar') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checar o repositório | |
uses: actions/checkout@v2 | |
- name: View the github context | |
run: echo "$GITHUB_CONTEXT" | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
- name: Obter detalhes do evento da issue | |
id: event_details | |
run: | | |
event_info="${{ github.event.issue.body }}" | |
get_event_values() { | |
local event_info="$1" | |
local key_name="$2" | |
echo "$event_info" | awk '/^###/ { key=$0; next }NF { print key ": " $0 }' | grep "$key_name" | sed 's/^.*: //' | |
} | |
extract_abbreviation() { | |
local input="$1" | |
echo "$input" | sed -E 's/.*\(([^)]+)\).*/\1/' | |
} | |
capitalize_first_letter() { | |
echo "$1" | awk '{ for(i=1;i<=NF;i++) $i=toupper(substr($i,1,1)) substr($i,2); }1' | |
} | |
event_name=$(get_event_values "$event_info" 'Nome do(a) Evento/Agenda') | |
event_year=$(get_event_values "$event_info" 'Ano do(a) Evento/Agenda') | |
event_month=$(get_event_values "$event_info" 'Mês do(a) Evento/Agenda') | |
event_day=$(get_event_values "$event_info" 'Dia do(a) Evento/Agenda') | |
event_type=$(get_event_values "$event_info" 'Tipo do(a) Evento/Agenda') | |
event_city=$(get_event_values "$event_info" 'Cidade do(a) Evento/Agenda') | |
event_state=$(get_event_values "$event_info" 'Estado Federativo do(a) Evento/Agenda') | |
if [[ $event_day == "_No response_" ]]; then | |
event_month=TBA | |
fi | |
if [[ $event_month == "To Be Announced" ]]; then | |
event_month=TBA | |
fi | |
event_url="${event_url,,}" | |
event_state=$(extract_abbreviation "${event_state}") | |
echo "event_name=${event_name}" >> $GITHUB_ENV | |
echo "event_city=${event_city}" >> $GITHUB_ENV | |
echo "event_state=${event_state}" >> $GITHUB_ENV | |
echo "event_year=${event_year}" >> $GITHUB_ENV | |
echo "event_month=${event_month}" >> $GITHUB_ENV | |
echo "event_day=${event_day}" >> $GITHUB_ENV | |
echo "event_type=${event_type}" >> $GITHUB_ENV | |
- name: Adiciona o Evento/Agenda no database.json | |
run: | | |
pip3 install -r src/requirements.txt | |
python3 src/remove_event.py | |
- name: Gera o markdown baseado no database.json | |
run: | | |
pip3 install -r src/requirements.txt | |
python3 src/generate_page.py | |
- name: Set up Git | |
run: | | |
git config --global user.name "${{ github.event.issue.user.login }}" | |
git config --global user.email "${{ github.event.issue.user.login }}@users.noreply.github.com" | |
- name: Criar uma nova branch | |
run: | | |
branch_name="feature/add-event-issue-${{ github.event.issue.number }}" | |
git checkout -b $branch_name | |
git add README.md src/db/database.json | |
git commit -m "Cancelando evento: ${{ env.event_name }}" | |
git push origin $branch_name | |
echo "branch_name=${branch_name}" >> $GITHUB_ENV | |
- name: Criar Pull Request | |
run: | | |
gh pr create \ | |
-B master \ | |
-H ${{ env.branch_name }} \ | |
--title "Agenda/Evento: ${{ env.event_name }}" \ | |
--body "Closes #${{ github.event.issue.number }}" \ | |
--label cancelar \ | |
--reviewer "${{ env.reviewers }}" | |
env: | |
GH_TOKEN: ${{ github.token }} |