octomation/go-service

View on GitHub
.github/workflows/cleanup.stale.yml

Summary

Maintainability
Test Coverage
name: Stale issues cleanup

on:
  schedule:
    - cron: 0 6 * * * # at 06:00 every day, UTC

  workflow_call:

  workflow_dispatch:
    inputs:
      reason:
        description: The reason for dispatching it manually.
        type: string
        default: manual healthcheck
        required: true

jobs:
  check:
    name: Checking
    runs-on: ubuntu-latest
    permissions:
      contents: write
      issues: write
      pull-requests: write

    steps:
      - name: Close stale issues and PRs
        uses: actions/stale@v9.0.0
        with:
          days-before-issue-stale: 30
          days-before-issue-close: 7
          exempt-all-issue-assignees: true
          exempt-all-issue-milestones: true
          exempt-issue-labels: 'status: pending'
          stale-issue-label: 'status: stale'
          stale-issue-message: >
            This issue has been automatically marked as stale because it has not had
            recent activity. It will be closed if no further action occurs. Thank you
            for your contributions.
          close-issue-message: >
            This issue was closed because it has been stalled for 7 days with no activity.

          days-before-pr-stale: 30
          days-before-pr-close: 7
          exempt-all-pr-assignees: true
          exempt-all-pr-milestones: true
          exempt-pr-labels: 'status: pending'
          stale-pr-label: 'status: stale'
          stale-pr-message: >
            This pull request has been automatically marked as stale because it has not had
            recent activity. It will be closed if no further action occurs. Thank you
            for your contributions.
          close-pr-message: >
            This pull request was closed because it has been stalled for 7 days with no activity.
          delete-branch: true

  notify:
    name: Notifying
    needs: [ check ]
    runs-on: ubuntu-latest
    if: failure() || success()

    steps:
      - name: Checkout the repository
        uses: actions/checkout@v4.1.1
        with: { fetch-depth: 0 }

      - name: Send notification
        uses: ./.github/actions/notify
        with:
          emoji: ⌛️
          channel: ${{ secrets.SLACK_WEBHOOK }}
          success: ${{ ! contains(needs.*.result, 'failure') }}