-
Notifications
You must be signed in to change notification settings - Fork 20
70 lines (56 loc) · 2.49 KB
/
pr-tracker.yml
File metadata and controls
70 lines (56 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: PR Tracker
on:
schedule:
- cron: "0 0 * * *" # Runs daily at midnight UTC
workflow_dispatch: # Allows manual trigger
jobs:
pr-summary:
runs-on: ubuntu-latest
steps:
# Step 1: Use Node.js version 20.x
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "20.x"
# Step 2: Checkout repository
- name: Checkout FSOC.V2
uses: actions/checkout@v2
# Step 3: Fetch PRs using GitHub API
- name: Fetch PRs
run: |
# Fetch the PRs and store the output in pr-summary.json
curl -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://github.com/FSOC-OSS/FSOC.V2/pulls?state=all" \
| tee pr-response.json # Save API response to a file
# Step 4: Debugging - Check response format
- name: Check API Response
run: |
cat pr-response.json # Output the raw API response to check the structure
# Step 5: Process the PRs
- name: Process PRs
run: |
jq '.[] | {title: .title, state: .state, merged: .merged_at, created_at: .created_at, user: .user.login}' pr-response.json > pr-summary.json
# Step 6: Filter and count PRs by date, list users
- name: Filter PRs by date
run: |
TODAY=$(date -u +"%Y-%m-%d")
# Extract all PRs created today
PR_COUNT=$(jq --arg TODAY "$TODAY" '[.[] | select(.created_at | startswith($TODAY))] | length' pr-summary.json)
# Extract all merged PRs today
MERGED_COUNT=$(jq --arg TODAY "$TODAY" '[.[] | select(.created_at | startswith($TODAY) and .merged != null)] | length' pr-summary.json)
# List of users who created PRs today
echo "Users who created PRs today:"
jq --arg TODAY "$TODAY" '.[] | select(.created_at | startswith($TODAY)) | .user.login' pr-summary.json
# List of users whose PRs were merged today
echo "Users whose PRs were merged today:"
jq --arg TODAY "$TODAY" '.[] | select(.created_at | startswith($TODAY) and .merged != null) | .user.login' pr-summary.json
# Output the total count
echo "Total PRs created today: $PR_COUNT"
echo "Total PRs merged today: $MERGED_COUNT"
#Step 7 download the result
- name: Upload PR summary artifact
uses: actions/upload-artifact@v3
with:
name: pr-summary
path: pr-summary.json