-
Notifications
You must be signed in to change notification settings - Fork 218
57 lines (49 loc) · 1.94 KB
/
list-unhealthy-branches.yml
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
name: List Unhealthy Branches
on:
schedule:
- cron: '0 3 * * fri'
jobs:
list:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: '18'
- name: List branches
id: list-branches
run: |
export SLACK_ATTACHMENTS_ILLEGAL=`node bin/github-actions/list-branches --illegal`
export SLACK_ATTACHMENTS_INACTIVE=`node bin/github-actions/list-branches --inactive`
echo "SLACK_ATTACHMENTS_ILLEGAL=$SLACK_ATTACHMENTS_ILLEGAL" >> $GITHUB_OUTPUT
echo "SLACK_ATTACHMENTS_INACTIVE=$SLACK_ATTACHMENTS_INACTIVE" >> $GITHUB_OUTPUT
echo "SLACK_ATTACHMENTS_LENGTH_ILLEGAL=$(echo $SLACK_ATTACHMENTS_ILLEGAL | jq '. | length')" >> $GITHUB_OUTPUT
echo "SLACK_ATTACHMENTS_LENGTH_INACTIVE=$(echo $SLACK_ATTACHMENTS_INACTIVE | jq '. | length')" >> $GITHUB_OUTPUT
- name: Slack Notification for illegal named branches
if: steps.list-branches.outputs.SLACK_ATTACHMENTS_LENGTH_ILLEGAL > 0
uses: sonots/slack-notice-action@v3
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: custom
payload: |
{
text: '<!channel> There is some branches *with illegal names* on GitHub.',
channel: '#ci',
attachments: ${{ steps.list-branches.outputs.SLACK_ATTACHMENTS_ILLEGAL }}
}
- name: Slack Notification for inactive branches
if: steps.list-branches.outputs.SLACK_ATTACHMENTS_LENGTH_INACTIVE > 0
uses: sonots/slack-notice-action@v3
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
status: custom
payload: |
{
text: '<!channel> There is some branches *that are no longer updated* on GitHub.',
channel: '#ci',
attachments: ${{ steps.list-branches.outputs.SLACK_ATTACHMENTS_INACTIVE }}
}