Skip to content

Create a next vatz discussion & milestone #67

Create a next vatz discussion & milestone

Create a next vatz discussion & milestone #67

name: Create a next vatz discussion & milestone
on:
workflow_dispatch:
schedule:
- cron: "0 2 * * 1" # Every Monday at 11 a.m(KST).
jobs:
create-bi-weekly:
runs-on: ubuntu-latest
steps:
- name: Check creation date # Step to determine if this is the second week because you have to create a 'Discussion' every two weeks
id: check_week
run: |
WEEK_NUM=`date -d ${{ vars.START_DATE }} +%U`
THIS_WEEK_NUM=`date +%U`
DIFF_WEEK_NUM=$( expr $THIS_WEEK_NUM - $WEEK_NUM )
if [ $(( DIFF_WEEK_NUM % 2)) -eq 0 ]; then
echo "This is the correct week"
echo "is_week=true" >> $GITHUB_OUTPUT
else
echo "This is not the correct week"
echo "is_week=false" >> $GITHUB_OUTPUT
fi
shell: bash
- name: Get meeting date
if: steps.check_week.outputs.is_week == 'true'
id: check_meeting_date
run: |
meeting=`date -d "wed" +"%Y-%m-%d"`
echo "meet_date=$meeting" >> $GITHUB_OUTPUT
shell: bash
- name: Get next discussion number
if: steps.check_week.outputs.is_week == 'true'
id: check_latest_discussion
run: |
# GitHub GraphQL API Endpoint
URL="https://api.github.com/graphql"
# GraphQL Query
QUERY='{
"query": "query { repository(owner: \"dsrvlabs\", name: \"vatz\") { discussions(first: 1, orderBy: {field: CREATED_AT, direction: DESC}) { nodes { title url createdAt author { login } } } } }"
}'
# Sending the request using curl
response=$(curl -s -X POST -H "Authorization: bearer ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/json" -d "$QUERY" $URL)
LASTEST=`echo $response | jq .data.repository.discussions.nodes[0].title | awk '{print $1 }' | sed 's/\"//g' | sed 's/\.//g'`
NEXT_NUM=$( expr $LASTEST + 1 )
echo "dis_num=$NEXT_NUM" >> $GITHUB_OUTPUT
shell: bash
- name: Generate new discussion
if: steps.check_latest_discussion.outputs.dis_num != ''
id: create_discussion
uses: abirismyname/create-discussion@v1.1.0
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
title: "${{ steps.check_latest_discussion.outputs.dis_num }}. VATZ biweekly meeting at ${{ steps.check_meeting_date.outputs.meet_date }}"
body: |
### 1. Overall
### 2. Statistic Rate
Sprint | Issue fulfillment | progress rate(%)
--: | :--: | :--:
repository-id: "${{ secrets.REPOSITORY_ID }}"
category-id: "${{ secrets.CATEGORY_ID }}"