-
Notifications
You must be signed in to change notification settings - Fork 1
89 lines (83 loc) · 3.78 KB
/
branch-pruner-advanced.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Branch-Pruner-Advanced | GitHub Action Workflow
#
# Description: Truncates the old commit history of multiple selected target branches
# Author: Sitdisch
# Source: https://github.com/myactionway/branch-pruner-workflows
# License: MIT
# Copyright (c) 2021 Sitdisch
#
# CAUTION: IT IS A POWERFUL TOOL AND YOU USE IT AT YOUR OWN RISK. CUTS CAN'T BE UNDONE.
name: 'Branch-Pruner-Advanced'
########################################################################
# DEFINE YOUR DEFAULTS (INPUTS & TRIGGERS) IN THE FOLLOWING
########################################################################
# INPUTS as environmental variables (env)
env:
TOKEN_NAME: # target token name; insert only the name never the real value e.g. 'BRANCH_PRUNER_TOKEN'
# To change predefined values, just override them
REPOSITORY: ${{ github.repository }} # target repository; predefined is the repo with this file
USER_NAME: 'github-actions[bot]' # user who should commit
USER_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com'
# TRIGGERS
on:
# push:
# schedule: # Check your schedule here => https://crontab.guru/
# - cron: '00 23 28 * *' # e.g. every 28th day of a month at 23:00
workflow_dispatch:
# No predefined inputs; The env defined in this file are used instead when this trigger is triggered.
########################################################################
# YOU CAN JUMP TO THE FIRST TARGET BRANCH DEFINITION BELOW
########################################################################
jobs:
branch-pruner-advanced:
name: ${{ matrix.NAME }}
runs-on: ubuntu-22.04
timeout-minutes: 8
strategy:
fail-fast: false
matrix:
include:
##############################################################
# FIRST TARGET BRANCH | DEFINE YOUR ENV IN THE FOLLOWING
##############################################################
- NAME: # e.g. 'Pruning Branch 1'
NEW_FIRST_COMMIT: # e.g. commit-hash or HEAD~N etc.
BRANCH: # branch to be pruned e.g. 'main'
# Your defaults will be used unless you redefine a following env
# TOKEN_NAME:
# REPOSITORY:
# USER_NAME:
# USER_EMAIL:
##############################################################
# SECOND TARGET BRANCH | DEFINE YOUR ENV IN THE FOLLOWING
##############################################################
- NAME: # e.g. 'Pruning Branch 2'
NEW_FIRST_COMMIT: # e.g. commit-hash or HEAD~N etc.
BRANCH: # branch to be pruned e.g. 'test'
# Your defaults will be used unless you redefine a following env
# TOKEN_NAME:
# REPOSITORY:
# USER_NAME:
# USER_EMAIL:
##############################################################
# THIRD TARGET BRANCH | FEEL FREE TO ADD MORE TARGET BRANCHES
##############################################################
#
# ...
#
####################################################################
# THAT'S IT; YOU DON'T HAVE TO DEFINE ANYTHING IN THE FOLLOWING
####################################################################
steps:
- uses: actions/checkout@v3
with:
repository: ${{ matrix.REPOSITORY || env.REPOSITORY }}
token: ${{ secrets[matrix.TOKEN_NAME] || secrets[env.TOKEN_NAME] }}
fetch-depth: '0'
ref: ${{ matrix.BRANCH || env.BRANCH }}
- uses: myactionway/branch-pruner-action@v2.0
with:
new_first_commit: ${{ matrix.NEW_FIRST_COMMIT }}
branch: ${{ matrix.BRANCH || env.BRANCH }}
user_name: ${{ matrix.USER_NAME || env.USER_NAME }}
user_email: ${{ matrix.USER_EMAIL || env.USER_EMAIL }}