File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Branch Age Notification
2
+
3
+ on :
4
+ schedule :
5
+ - cron : ' 0 12 * * 5' # Run every Friday at 12pm CET
6
+
7
+ jobs :
8
+ branch-age-check :
9
+ runs-on : ubuntu-latest
10
+ steps :
11
+ - uses : actions/checkout@v2
12
+ - name : Check for branches older than 180 days
13
+ uses : actions/github-script@v6
14
+ with :
15
+ script : |
16
+ const { data: branches } = await github.repos.listBranches({
17
+ owner: context.repo.owner,
18
+ repo: context.repo.repo,
19
+ });
20
+ const oldBranches = branches.filter(branch => {
21
+ const lastCommitDate = new Date(branch.commit.commit.author.date);
22
+ const daysOld = (new Date() - lastCommitDate) / (1000 * 60 * 60 * 24);
23
+ return daysOld > 180;
24
+ });
25
+ if (oldBranches.length > 0) {
26
+ console.log(`Found ${oldBranches.length} branches older than 180 days.`);
27
+ // Add notification logic here
28
+ } else {
29
+ console.log('No branches older than 180 days were found.');
30
+ }
You can’t perform that action at this time.
0 commit comments