Skip to content

.github/workflows/ISSUE_CREATION_WORKFLOW.yml #6

.github/workflows/ISSUE_CREATION_WORKFLOW.yml

.github/workflows/ISSUE_CREATION_WORKFLOW.yml #6

# This workflow uses actions that are not certified by GitHub.
# São fornecidas por terceiros e regidas por
# termos de serviço, política de privacidade e suporte separados
# documentação.
name: Weekly Team Sync
on:
workflow_dispatch:
inputs:
input:
description: "Criação de issue"
required: false
default: "Issue criada"
schedule:
- cron: 30 22 * * 2
env:
MONTH_01: "Janeiro"
MONTH_02: "Fevereiro"
MONTH_03: "Março"
MONTH_04: "Abril"
MONTH_05: "Maio"
MONTH_06: "Junho"
MONTH_07: "Julho"
MONTH_08: "Agosto"
MONTH_09: "Setembro"
MONTH_10: "Outubro"
MONTH_11: "Novembro"
MONTH_12: "Dezembro"
# Change this variable for changing the meeting weekday
DATE_WEEKDAY: "wednesday"
# Change this variable for changing the meeting interval
INTERVAL: "14 days"
FIRST_RUN_DATE: "2024-02-13"
jobs:
weekindex:
runs-on: ubuntu-latest
outputs:
weekindex: ${{ steps.calculate.outputs.weekindex }}
steps:
- name: Calculate weekdiff
id: calculate
run: |
current_date=$(date +%Y-%m-%d)
start=$(date -d ${{ env.FIRST_RUN_DATE }} +%s)
end=$(date -d $current_date +%s)
weekdiff=$(((end-start) / 60 / 60 / 24 / 7))
weekindex=$((weekdiff % 2))
echo "weekindex=$weekindex" >> "$GITHUB_OUTPUT"
echo "FIRST_RUN_DATE: ${{ env.FIRST_RUN_DATE }}" >> $GITHUB_STEP_SUMMARY
echo "current_date: $current_date" >> $GITHUB_STEP_SUMMARY
echo "weekdiff: $weekdiff" >> $GITHUB_STEP_SUMMARY
echo "weekindex: $weekindex" >> $GITHUB_STEP_SUMMARY
if [ $weekindex -eq 0 ]; then
echo "🟢 It's the first week of the bi-weekly cycle. The action is going to run." >> $GITHUB_STEP_SUMMARY
else
echo "🔴 It's the second week of the bi-weekly cycle. The action is going to be skipped." >> $GITHUB_STEP_SUMMARY
fi
create_issue:
if: ${{ needs.weekindex.outputs.weekindex == 0 }}
name: Create team sync issue
runs-on: ubuntu-latest
needs:
- weekindex
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
permissions:
issues: write
steps:
- name: Extract issue template and generate title
uses: imjohnbo/extract-issue-template-fields@v1
id: extract
with:
path: .github/ISSUE_TEMPLATE/reuniao.md
- name: Get meeting date
id: date
run: |
day=$(date -d "$INTERVAL" +%d)
month_num=$(date -d "$INTERVAL" +%m)
month_var="MONTH_$month_num"
month=$(eval echo ${!month_var})
year=$(date -d "$INTERVAL" +%Y)
meeting_date="$day de $month de $year"
echo "::set-output name=date::$meeting_date"
- name: Create meeting issue
uses: imjohnbo/issue-bot@v3
with:
assignees: ${{ steps.extract.outputs.assignees }}
labels: ${{ steps.extract.outputs.labels }}
title: "[Reunião] Geral: ${{ steps.date.outputs.date }}"
body: ${{ steps.extract.outputs.body }}
project: ${{ steps.extract.outputs.project }}
pinned: false
close-previous: false