-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
46 lines (43 loc) · 1.54 KB
/
action.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
# Branch-Pruner | GitHub Action
#
# Description: Truncates the old commit history of one/multiple selected target branch(es)
# Author: Sitdisch
# Version: v2.0
# Source: https://github.com/myactionway/branch-pruner-action
# 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'
author: 'Sitdisch'
description: "Reduces the repo-size by manually & automatically truncating a branch's history. Newer commits & file versions are preserved"
branding:
icon: scissors
color: red
inputs:
new_first_commit:
description: 'New first commit'
required: true
branch:
description: 'Branch to be pruned'
required: true
user_name:
description: 'User who should commit'
default: 'github-actions[bot]'
user_email:
description: 'User e-mail address'
default: '41898282+github-actions[bot]@users.noreply.github.com'
runs:
using: "composite"
steps:
- run: |
git config --local user.email ${{ inputs.user_email }}
git config --local user.name ${{ inputs.user_name }}
COMMIT_ID=$(git rev-parse ${{ inputs.new_first_commit }})
COMMIT_MESSAGE=$(git log --format=%B -n 1 "$COMMIT_ID" )" [ Branch-Pruner[bot]: Earlier Commits Truncated ]"
git checkout --orphan pruner_temp_branch "$COMMIT_ID"
git commit -m "$COMMIT_MESSAGE"
git rebase --onto pruner_temp_branch $COMMIT_ID ${{ inputs.branch }}
git branch -D pruner_temp_branch
git push origin HEAD --force
shell: bash