-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
81 lines (66 loc) · 1.9 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
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
name: 'Rebase'
description: 'Rebase and update one branch with another.'
inputs:
target:
description: 'Target branch you wish to update.'
required: true
base:
description: 'Base branch to use to rebase target.'
required: true
force:
description: 'Force push.'
required: false
default: 'false'
remote:
description: 'The remote to use'
required: false
default: 'origin'
continue-on-error:
description: 'Continue when rebasing fails'
required: false
default: 'true' # TODO: change to false in next major version
token:
description: 'GitHub token to use. If passed, takes precedence over the `app-id` and `app-private-key` inputs.'
app-id:
description: 'The app ID of the app.'
private-key:
description: 'The private key of the app.'
runs:
using: composite
steps:
- uses: myparcelnl/actions/get-github-token@v4
id: token
with:
token: ${{ inputs.token }}
app-id: ${{ inputs.app-id }}
private-key: ${{ inputs.private-key }}
- uses: actions/checkout@v4
with:
token: ${{ steps.token.outputs.token }}
ref: ${{ inputs.target }}
fetch-depth: 0
- name: 'Rebase'
id: rebase
shell: bash
#language=bash
run: |
FAILED=false
git rebase "${{ inputs.remote }}/${{ inputs.base }}" || (FAILED=true && git rebase --abort)
if [ "$FAILED" = true ]; then
echo "failed=true" >> $GITHUB_OUTPUT
if [ "${{ inputs.continue-on-error }}" = false ]; then
exit 1
fi
fi
- name: 'Push'
if: inputs.force != 'true' && steps.rebase.outputs.failed != 'true'
shell: bash
#language=bash
run: |
git push
- name: 'Force push'
if: inputs.force == 'true' && steps.rebase.outputs.failed != 'true'
shell: bash
#language=bash
run: |
git push --force