-
Notifications
You must be signed in to change notification settings - Fork 0
166 lines (145 loc) · 4.38 KB
/
Copy pathrebase.yml
File metadata and controls
166 lines (145 loc) · 4.38 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
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:
runs-on: ubuntu-slim
timeout-minutes: 5
environment:
name: admin
deployment: false
outputs:
repos: ${{ steps.get-repos.outputs.repositories }}
permissions:
contents: read
id-token: write
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
filter: 'tree:0'
persist-credentials: false
show-progress: false
- name: Get GitHub token
id: get-github-token
uses: ./actions/get-github-token
with:
profile-name: admin
- 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: ${{ steps.get-github-token.outputs.token }}
repository: ${{ inputs.repository }}
rebase:
name: "rebase-${{ matrix.repo }}"
needs: get-repos
if: needs.get-repos.outputs.repos != '[]'
runs-on: ubuntu-24.04
timeout-minutes: 10
concurrency:
group: "rebase-${{ matrix.repo }}"
cancel-in-progress: false
environment:
name: rebase
deployment: false
permissions:
contents: read
id-token: write
strategy:
fail-fast: false
max-parallel: 2
matrix:
repo: ${{ fromJSON(needs.get-repos.outputs.repos) }}
steps:
- name: Get GitHub token
id: get-github-token
uses: martincostello/github-automation/actions/get-github-token@279f5d3cc244dfdd9bb1197d2ab6996c37cb4486 # get-github-token/v4.3.3
with:
profile-name: rebase
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: true # zizmor: ignore[artipacked] Needed to push commits
ref: ${{ inputs.branch }}
repository: ${{ matrix.repo }}
show-progress: false
submodules: recursive
token: ${{ steps.get-github-token.outputs.token }}
- name: Rebase ${{ inputs.branch }}
uses: martincostello/rebaser@abc4bb4f3290930bbae1f9d6dd04ce3e416dd5f2 # v3.0.2
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}."
}