list-unhealthy-branches.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. name: List Unhealthy Branches
  2. on:
  3. schedule:
  4. - cron: '0 3 * * fri'
  5. jobs:
  6. list:
  7. runs-on: ubuntu-latest
  8. steps:
  9. - uses: actions/checkout@v4
  10. with:
  11. fetch-depth: 0
  12. - uses: actions/setup-node@v4
  13. with:
  14. node-version: '18'
  15. - name: List branches
  16. id: list-branches
  17. run: |
  18. export SLACK_ATTACHMENTS_ILLEGAL=`node bin/github-actions/list-branches --illegal`
  19. export SLACK_ATTACHMENTS_INACTIVE=`node bin/github-actions/list-branches --inactive`
  20. echo "SLACK_ATTACHMENTS_ILLEGAL=$SLACK_ATTACHMENTS_ILLEGAL" >> $GITHUB_OUTPUT
  21. echo "SLACK_ATTACHMENTS_INACTIVE=$SLACK_ATTACHMENTS_INACTIVE" >> $GITHUB_OUTPUT
  22. echo "SLACK_ATTACHMENTS_LENGTH_ILLEGAL=$(echo $SLACK_ATTACHMENTS_ILLEGAL | jq '. | length')" >> $GITHUB_OUTPUT
  23. echo "SLACK_ATTACHMENTS_LENGTH_INACTIVE=$(echo $SLACK_ATTACHMENTS_INACTIVE | jq '. | length')" >> $GITHUB_OUTPUT
  24. - name: Slack Notification for illegal named branches
  25. if: steps.list-branches.outputs.SLACK_ATTACHMENTS_LENGTH_ILLEGAL > 0
  26. uses: sonots/slack-notice-action@v3
  27. env:
  28. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  29. with:
  30. status: custom
  31. payload: |
  32. {
  33. text: '<!channel> There is some branches *with illegal names* on GitHub.',
  34. channel: '#ci',
  35. attachments: ${{ steps.list-branches.outputs.SLACK_ATTACHMENTS_ILLEGAL }}
  36. }
  37. - name: Slack Notification for inactive branches
  38. if: steps.list-branches.outputs.SLACK_ATTACHMENTS_LENGTH_INACTIVE > 0
  39. uses: sonots/slack-notice-action@v3
  40. env:
  41. SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
  42. with:
  43. status: custom
  44. payload: |
  45. {
  46. text: '<!channel> There is some branches *that are no longer updated* on GitHub.',
  47. channel: '#ci',
  48. attachments: ${{ steps.list-branches.outputs.SLACK_ATTACHMENTS_INACTIVE }}
  49. }