131 lines (115 loc) · 3.46 KB
/
rebase.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: rebase
on:
workflow_call:
inputs:
branch:
description: "The branch to rebase."
required: false
type: string
default: "dotnet-vnext"
repository:
description: "The repository to rebase."
required: true
type: string
force:
description: "Whether to rebase even if the branch has no conflicts."
required: false
type: boolean
default: false
base:
description: "The branch to rebase against."
required: false
type: string
default: ""
workflow_dispatch:
inputs:
branch:
description: "The branch to rebase."
required: false
type: choice
options:
- "dotnet-vnext"
- "dotnet-nightly"
default: "dotnet-vnext"
repository:
description: "An optional single repository to rebase."
required: false
type: string
default: ""
force:
description: "Whether to rebase even if the branch has no conflicts."
required: false
type: boolean
default: false
base:
description: "The branch to rebase against."
required: false
type: choice
options:
- "main"
- "dotnet-vnext"
default: "main"
permissions: {}
env:
FORCE_COLOR: 3
TERM: xterm
jobs:
get-repos:
outputs:
repos: ${{ steps.get-repos.outputs.repositories }}
permissions: {}
runs-on: [ ubuntu-latest ]
steps:
- name: Checkout code
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
- name: Get repositories to rebase
uses: ./actions/get-rebase-repos
id: get-repos
with:
base: ${{ inputs.base }}
branch: ${{ inputs.branch }}
force: ${{ inputs.force }}
github-token: ${{ secrets.ACCESS_TOKEN }}
repository: ${{ inputs.repository }}
rebase:
name: "rebase-${{ matrix.repo }}"
needs: get-repos
if: needs.get-repos.outputs.repos != '[]'
runs-on: [ ubuntu-latest ]
concurrency:
group: "rebase-${{ matrix.repo }}"
cancel-in-progress: false
strategy:
fail-fast: false
max-parallel: 2
matrix:
repo: ${{ fromJSON(needs.get-repos.outputs.repos) }}
steps:
- name: Checkout code
uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5
with:
fetch-depth: 0
ref: ${{ inputs.branch }}
repository: ${{ matrix.repo }}
token: ${{ secrets.ACCESS_TOKEN }}
- name: Rebase ${{ inputs.branch }}
uses: martincostello/rebaser@e5e6cf46f65f092d13e70a90829d7a93db20fe44 # v2.0.1
id: rebase
with:
branch: origin/${{ inputs.base || 'main' }}
user-email: ${{ vars.REBASE_GIT_COMMIT_USER_EMAIL }}
user-name: ${{ vars.REBASE_GIT_COMMIT_USER_NAME }}
- name: Push changes
if: steps.rebase.outputs.result == 'success'
env:
BRANCH_NAME: ${{ inputs.branch }}
REPO_NAME: ${{ matrix.repo }}
shell: pwsh
run: |
git push --force-with-lease origin "${env:BRANCH_NAME}"
if ($LASTEXITCODE -eq 0) {
Write-Output "::notice::Rebased the ${env:BRANCH_NAME} branch of ${env:REPO_NAME}."
}
else {
Write-Output "::error::Could not push changes to the ${env:BRANCH_NAME} branch of ${env:REPO_NAME}."
}