Skip to content

Commit 7bce060

Browse files
committed
Update TCU community repository activity monitor
1 parent 7256b04 commit 7bce060

1 file changed

Lines changed: 17 additions & 41 deletions

File tree

.github/workflows/tcu-community-repository-activity-monitor.yml

Lines changed: 17 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,9 @@ on:
99
pull_request:
1010
types: [opened, synchronize, reopened, closed]
1111

12-
# Trigger when a new repository is created
12+
# Trigger custom events like "repository created" from a GitHub App via webhook → repository_dispatch
1313
repository_dispatch:
14-
types: [created]
15-
16-
# Trigger on repository creation/deletion
17-
repository:
18-
types: [created, deleted, transferred]
14+
types: [repository-created, repository-deleted, repository-transferred]
1915

2016
# Trigger on issue events
2117
issues:
@@ -28,36 +24,31 @@ jobs:
2824
monitor_activity:
2925
runs-on: ubuntu-latest
3026
steps:
31-
# Step 1: Check out the repository
3227
- name: Checkout repository
3328
uses: actions/checkout@v3
34-
35-
# Step 2: Get repository information
29+
3630
- name: Get repository information
3731
id: repo-info
3832
run: |
3933
echo "repo-name=${{ github.repository }}" >> $GITHUB_OUTPUT
4034
echo "event-name=${{ github.event_name }}" >> $GITHUB_OUTPUT
4135
echo "actor=${{ github.actor }}" >> $GITHUB_OUTPUT
4236
echo "timestamp=$(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_OUTPUT
43-
44-
# Step 3: Set event-specific details
37+
4538
- name: Set event details
4639
id: event-details
4740
run: |
48-
# Default values
4941
EVENT_TYPE="unknown"
5042
EVENT_DESCRIPTION="Unknown activity"
51-
52-
# Determine event type and description based on the trigger event
43+
5344
if [[ "${{ github.event_name }}" == "push" ]]; then
5445
EVENT_TYPE="push"
5546
EVENT_DESCRIPTION="Pushed to branch ${GITHUB_REF#refs/heads/}"
56-
47+
5748
elif [[ "${{ github.event_name }}" == "pull_request" ]]; then
5849
PR_ACTION="${{ github.event.action }}"
5950
EVENT_TYPE="pull_request_${PR_ACTION}"
60-
51+
6152
if [[ "$PR_ACTION" == "opened" ]]; then
6253
EVENT_DESCRIPTION="Opened pull request #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}"
6354
elif [[ "$PR_ACTION" == "closed" ]]; then
@@ -72,63 +63,49 @@ jobs:
7263
elif [[ "$PR_ACTION" == "reopened" ]]; then
7364
EVENT_DESCRIPTION="Reopened pull request #${{ github.event.pull_request.number }}"
7465
fi
75-
76-
elif [[ "${{ github.event_name }}" == "repository" ]]; then
77-
REPO_ACTION="${{ github.event.action }}"
78-
EVENT_TYPE="repository_${REPO_ACTION}"
79-
80-
if [[ "$REPO_ACTION" == "created" ]]; then
81-
EVENT_DESCRIPTION="Created new repository ${{ github.repository }}"
82-
elif [[ "$REPO_ACTION" == "deleted" ]]; then
83-
EVENT_DESCRIPTION="Deleted repository ${{ github.repository }}"
84-
elif [[ "$REPO_ACTION" == "transferred" ]]; then
85-
EVENT_DESCRIPTION="Transferred repository ${{ github.repository }}"
86-
fi
87-
66+
8867
elif [[ "${{ github.event_name }}" == "issues" ]]; then
8968
ISSUE_ACTION="${{ github.event.action }}"
9069
EVENT_TYPE="issue_${ISSUE_ACTION}"
91-
70+
9271
if [[ "$ISSUE_ACTION" == "opened" ]]; then
9372
EVENT_DESCRIPTION="Opened issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}"
9473
elif [[ "$ISSUE_ACTION" == "closed" ]]; then
9574
EVENT_DESCRIPTION="Closed issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}"
9675
elif [[ "$ISSUE_ACTION" == "reopened" ]]; then
9776
EVENT_DESCRIPTION="Reopened issue #${{ github.event.issue.number }}: ${{ github.event.issue.title }}"
9877
fi
78+
79+
elif [[ "${{ github.event_name }}" == "repository_dispatch" ]]; then
80+
EVENT_TYPE="${{ github.event.action }}"
81+
EVENT_DESCRIPTION="External repo activity: ${{ github.event.client_payload.event_description }}"
9982
fi
100-
101-
# Output the determined event type and description
83+
10284
echo "event-type=${EVENT_TYPE}" >> $GITHUB_OUTPUT
10385
echo "event-description=${EVENT_DESCRIPTION}" >> $GITHUB_OUTPUT
10486
105-
# Step 4: Prepare summary for notifications
10687
- name: Create activity summary
10788
id: activity-summary
10889
run: |
109-
# Create summary string for notifications
11090
SUMMARY="${{ steps.event-details.outputs.event-description }}"
11191
echo "summary=${SUMMARY}" >> $GITHUB_OUTPUT
112-
113-
# Create a detailed message for email and dashboard
92+
11493
DETAILS="
11594
Repository Activity Notification
116-
95+
11796
Event: ${{ steps.event-details.outputs.event-type }}
11897
Description: ${{ steps.event-details.outputs.event-description }}
11998
Repository: ${{ github.repository }}
12099
User: ${{ github.actor }}
121100
Time: ${{ steps.repo-info.outputs.timestamp }}
122-
101+
123102
View details at: https://github.com/${{ github.repository }}
124103
"
125-
# Use a delimiter for multiline output
126104
delimiter="EOF"
127105
echo "details<<$delimiter" >> $GITHUB_OUTPUT
128106
echo "$DETAILS" >> $GITHUB_OUTPUT
129107
echo "$delimiter" >> $GITHUB_OUTPUT
130108
131-
# Step 5: Update community dashboard
132109
- name: Update community dashboard
133110
uses: peter-evans/repository-dispatch@v2
134111
with:
@@ -144,7 +121,6 @@ jobs:
144121
"timestamp": "${{ steps.repo-info.outputs.timestamp }}"
145122
}
146123
147-
# Step 6: Send email notification
148124
- name: Send email notification
149125
uses: dawidd6/action-send-mail@v3
150126
with:

0 commit comments

Comments
 (0)