From 79274188804f6481f0869cbab9232c27cdd83836 Mon Sep 17 00:00:00 2001 From: sichoi42 <42.4.sichoi@gmail.com> Date: Mon, 22 Apr 2024 20:49:40 +0900 Subject: [PATCH] [BE] FEAT: cleanup-stale-branch action (dry-run) --- .github/workflows/branch-cleaner.yaml | 40 +++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/branch-cleaner.yaml diff --git a/.github/workflows/branch-cleaner.yaml b/.github/workflows/branch-cleaner.yaml new file mode 100644 index 000000000..d1179e514 --- /dev/null +++ b/.github/workflows/branch-cleaner.yaml @@ -0,0 +1,40 @@ +name: Cleaning Up Stale Branches + +permissions: + contents: write + +on: + workflow_dispatch: + schedule: + - cron: "0 0 * * *" # Every day at 00:00 UTC (KST 09:00) + +env: + DAYS_BEFORE_STALE: 30 + DAYS_BEFORE_DELETE: 7 + +jobs: + cleanup-stale-branches: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Cleaning up Stale Branches + uses: sichoi42/cleanup-stale-branch@v1 + id: stale + with: + days-before-stale: ${{ env.DAYS_BEFORE_STALE }} + days-before-delete: ${{ env.DAYS_BEFORE_DELETE }} + ignoring-branches: "main,dev,onboard,nestJS" + ignore-branches-pattern: "release/*" + # FIXME: Set dry-run to false when you are ready to delete branches + dry-run: true + use-webhook: true + webhook-url: ${{ secrets.DISCORD_GITHUB_WEBHOOK_URL }} + webhook-type: "discord" + stale-branch-message: > + This branch is considered stale because ${{ env.DAYS_BEFORE_STALE }} days have passed since the last commit. + If you still need this branch, please push a new commit to keep it alive. + If not, this branch will be deleted in ${{ env.DAYS_BEFORE_DELETE }} days. + delete-branch-message: > + This branch was deleted because ${{ env.DAYS_BEFORE_DELETE }} days have passed since the last commit. + - name: Print outputs + run: echo ${{ format('{0},{1}', toJSON(steps.stale.outputs.staled-branches), toJSON(steps.stale.outputs.deleted-branches)) }}