-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
51 lines (46 loc) · 1.48 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
47
48
49
50
51
name: 'Goragit'
description: 'Ultimate Git workflow, not for people who cannot use Git properly.'
author: 'narze'
branding:
icon: delete
color: red
inputs:
author_name:
description: 'The author name of the commit'
default: 'github-actions'
author_email:
description: 'The author email of the commit'
default: 'github-actions@noreply.github.com'
github_token_with_repo_scope:
description: 'GitHub Personal Access Token (PAT) with Repo scope'
required: true
i_understand_that_this_workflow_will_goragodize_my_repo:
required: true
keep_git_history_in_message:
description: 'Keep git history in the message'
default: 'false'
runs:
using: 'composite'
steps:
- shell: bash
run: |
COMMIT_COUNT=$(git rev-list HEAD --count)
if [ "$COMMIT_COUNT" == "1" ]
then
exit 0
fi
MSG=$(git log -1 --pretty=%B)
if [ "${{ inputs.keep_git_history_in_message }}" != "false" ]
then
MSG=$(git log --pretty=%B)
fi
git config user.name ${{ inputs.author_name }}
git config user.email ${{ inputs.author_email }}
git checkout --orphan the_main
git remote rm origin
git remote add origin https://${{ github.actor }}:${{ inputs.github_token_with_repo_scope }}@github.com/${{ github.repository }}.git
git add -A
git commit -am "$MSG"
git branch -D main
git branch -m main
git push -f origin main