Repository navigation
Expand file tree
/
Copy pathinitialize-commercial-branch.yml
More file actions
172 lines (158 loc) · 7.15 KB
/
Copy pathinitialize-commercial-branch.yml
File metadata and controls
172 lines (158 loc) · 7.15 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
167
168
169
170
171
172
name: Initialize Commercial Branch
on:
workflow_dispatch:
inputs:
oss_repo:
description: 'Open source repository to copy from (format: org/repo-name)'
required: true
type: string
oss_branch:
description: 'Branch in the OSS repository to copy. Mutually exclusive with oss_tag.'
required: false
type: string
default: ''
oss_tag:
description: 'Tag in the OSS repository to copy. Mutually exclusive with oss_branch. When used, commercial_branch is required.'
required: false
type: string
default: ''
commercial_repo:
description: 'Commercial repository to create the branch in (format: org/repo-name)'
required: true
type: string
commercial_branch:
description: 'Target branch name in the commercial repo. Defaults to oss_branch. Required when oss_tag is used.'
required: false
type: string
default: ''
set_default_branch:
description: 'Set the new branch as the default branch of the commercial repo'
required: false
type: boolean
default: false
token:
description: 'GitHub token with contents: write on the commercial repo. Falls back to the GH_ACTIONS_REPO_TOKEN organization secret if not provided.'
required: false
type: string
default: ''
workflow_call:
inputs:
oss_repo:
description: 'Open source repository to copy from (format: org/repo-name)'
required: true
type: string
oss_branch:
description: 'Branch in the OSS repository to copy. Mutually exclusive with oss_tag.'
required: false
type: string
default: ''
oss_tag:
description: 'Tag in the OSS repository to copy. Mutually exclusive with oss_branch. When used, commercial_branch is required.'
required: false
type: string
default: ''
commercial_repo:
description: 'Commercial repository to create the branch in (format: org/repo-name)'
required: true
type: string
commercial_branch:
description: 'Target branch name in the commercial repo. Defaults to oss_branch. Required when oss_tag is used.'
required: false
type: string
default: ''
set_default_branch:
description: 'Set the new branch as the default branch of the commercial repo'
required: false
type: boolean
default: false
secrets:
token:
description: 'GitHub token with contents: write (and administration: write if set_default_branch is true) on the commercial repo. Falls back to the GH_ACTIONS_REPO_TOKEN organization secret if not provided.'
required: false
permissions:
contents: read
jobs:
initialize:
runs-on: ubuntu-latest
steps:
- name: Checkout spring-cloud-github-actions
uses: actions/checkout@v4
- name: Create commercial branch from OSS
id: create-branch
uses: ./.github/actions/create-commercial-branch
with:
oss-repo: ${{ inputs.oss_repo }}
oss-branch: ${{ inputs.oss_branch }}
oss-tag: ${{ inputs.oss_tag }}
commercial-repo: ${{ inputs.commercial_repo }}
commercial-branch: ${{ inputs.commercial_branch }}
token: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}
- name: Copy settings.xml to new branch
uses: ./.github/actions/copy-settings-xml
with:
repository: ${{ inputs.commercial_repo }}
source-branch: ${{ steps.create-branch.outputs.previous-default-branch }}
target-branch: ${{ steps.create-branch.outputs.commercial-branch }}
token: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}
- name: Update workflows for commercial repo
uses: ./.github/actions/update-oss-workflows-to-commercial
with:
repository: ${{ inputs.commercial_repo }}
branch: ${{ steps.create-branch.outputs.commercial-branch }}
token: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}
- name: Update license headers
uses: ./.github/actions/update-license-headers
with:
repository: ${{ inputs.commercial_repo }}
branch: ${{ steps.create-branch.outputs.commercial-branch }}
token: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}
- name: Update repositories to commercial Broadcom repositories
uses: ./.github/actions/update-commercial-repositories
with:
repository: ${{ inputs.commercial_repo }}
branch: ${{ steps.create-branch.outputs.commercial-branch }}
token: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}
- name: Update distribution management
uses: ./.github/actions/update-distribution-management
with:
repository: ${{ inputs.commercial_repo }}
branch: ${{ steps.create-branch.outputs.commercial-branch }}
token: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}
- name: Update Antora playbook on docs-build branch
uses: ./.github/actions/update-antora-playbook
with:
repository: ${{ inputs.commercial_repo }}
branch: ${{ steps.create-branch.outputs.commercial-branch }}
token: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}
# Only runs when we are promoting this branch to the new default.
# Source is the *old* default branch (captured before any changes), so the
# copy happens before we switch the default pointer.
- name: Copy dependabot config to new branch
if: ${{ inputs.set_default_branch }}
uses: ./.github/actions/copy-dependabot-config
with:
repository: ${{ inputs.commercial_repo }}
source-branch: ${{ steps.create-branch.outputs.previous-default-branch }}
target-branch: ${{ steps.create-branch.outputs.commercial-branch }}
token: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}
# Runs last so the dependabot config is already committed before the
# default branch pointer moves.
- name: Set new default branch
if: ${{ inputs.set_default_branch }}
shell: bash
env:
GH_TOKEN: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}
run: |
BRANCH="${{ steps.create-branch.outputs.commercial-branch }}"
REPO="${{ inputs.commercial_repo }}"
echo "Setting '${BRANCH}' as the default branch of ${REPO}..."
gh repo edit "$REPO" --default-branch "$BRANCH"
echo "Default branch updated to '${BRANCH}'."
- name: Update projects.json
uses: ./.github/actions/update-projects-json
with:
oss-repo: ${{ inputs.oss_repo }}
oss-branch: ${{ inputs.oss_branch }}
commercial-branch: ${{ steps.create-branch.outputs.commercial-branch }}
set-default-branch: ${{ inputs.set_default_branch }}
token: ${{ inputs.token || secrets.token || secrets.GH_ACTIONS_REPO_TOKEN }}