-
Notifications
You must be signed in to change notification settings - Fork 196
48 lines (40 loc) · 2.06 KB
/
StaleBranch.yml
File metadata and controls
48 lines (40 loc) · 2.06 KB
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
name: (Scheduled) Stale branch removal
permissions:
contents: write
pull-requests: read
# This workflow is designed to be run in the days up to, and including, a "deletion day", specified by 'DeleteOnDayOfMonth' in env: in https://github.com/MicrosoftDocs/tcp-workflows/blob/workflows-prod/.github/workflows/Shared-StaleBranch.yml.
# On the days leading up to "deletion day", the workflow will report the branches to be deleted. This lets users see which branches will be deleted. On "deletion day", those branches are deleted.
# The workflow should not be configured to run after "deletion day" so that users can review the branches were deleted.
# Recommendation: configure cron to run on days 1,15-31 where 1 is what's configured in 'DeleteOnDayOfMonth'. If 'DeleteOnDayOfMonth' is set to something else, update cron to run the two weeks leading up to it.
on:
schedule:
- cron: "0 9 1,15-31 * *"
workflow_dispatch:
jobs:
config:
if: github.repository_owner == 'MicrosoftDocs'
runs-on: ubuntu-latest
outputs:
RepoBranchSkipList: ${{ steps.read.outputs.RepoBranchSkipList }}
ReportOnly: ${{ steps.read.outputs.ReportOnly }}
steps:
- uses: actions/checkout@v5
with:
sparse-checkout: .github/workflow-config.json
sparse-checkout-cone-mode: false
- id: read
shell: pwsh
run: |
$Config = (Get-Content '.github/workflow-config.json' | ConvertFrom-Json).StaleBranch
"RepoBranchSkipList=$($Config.RepoBranchSkipList | ConvertTo-Json -Compress)" >> $Env:GITHUB_OUTPUT
"ReportOnly=$("$($Config.ReportOnly)".ToLower())" >> $Env:GITHUB_OUTPUT
stale-branch:
if: github.repository_owner == 'MicrosoftDocs'
needs: config
uses: MicrosoftDocs/tcp-workflows/.github/workflows/Shared-StaleBranch.yml@workflows-prod
with:
PayloadJson: ${{ toJSON(github) }}
RepoBranchSkipList: ${{ needs.config.outputs.RepoBranchSkipList }}
ReportOnly: ${{ fromJSON(needs.config.outputs.ReportOnly) }}
secrets:
AccessToken: ${{ secrets.GITHUB_TOKEN }}