Issue Summary #42
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: Issue Summary | |
on: | |
schedule: | |
- cron: "*/6 * * * *" | |
jobs: | |
summary: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version: "16" # Use Node.js 16 | |
- name: Install jq | |
run: sudo apt-get install jq -y | |
- name: Generate Issue Summary | |
id: generate_summary | |
run: | | |
SUMMARY="| Date | Opened | Closed |\n| ---- | ------ | ------ |" | |
# Fetch all issues and process the JSON response using jq | |
ISSUES=$(curl -s "https://api.github.com/repos/${{ github.repository }}/issues?state=all&per_page=100" | jq -r '.[] | "\(.created_at[0:10]) \(.state)"') | |
# Count the opened and closed issues for each day | |
while IFS= read -r LINE; do | |
DATE=$(echo "$LINE" | cut -d' ' -f1) | |
STATE=$(echo "$LINE" | cut -d' ' -f2) | |
if [ "$STATE" == "open" ]; then | |
OPENED=$((OPENED + 1)) | |
else | |
CLOSED=$((CLOSED + 1)) | |
fi | |
SUMMARY="$SUMMARY\n| $DATE | $OPENED | $CLOSED |" | |
done <<< "$ISSUES" | |
echo "$SUMMARY" > issue_summary.txt | |
- name: Create Issue | |
uses: peter-evans/create-issue@v4 | |
with: | |
title: "Issue Summary - $(date +'%Y-%m-%d')" | |
body: ${{ steps.generate_summary.outputs.stdout }} # Use the generated summary as the issuing body |