Merge pull request #29488 from QuadmanSWE/assume-default-branch-main
Assume default branch "main" with scaffolder action publish:github
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
---
|
||||
'@backstage/plugin-scaffolder-backend-module-github': minor
|
||||
'@backstage/create-app': patch
|
||||
---
|
||||
|
||||
**BREAKING** The `publish:github` scaffolder action now defaults to initializing with a branch named "main" instead of "master" when creating new repositories.
|
||||
|
||||
If you or your organization have relied on all new github repositories having a default branch name of "master" you **must** set the `defaultBranch: 'master'` in your existing templates that feature the `publish:github` scaffolder action.
|
||||
|
||||
To keep using the name "master" for your new github repos, these are the **required** changes:
|
||||
|
||||
```diff
|
||||
- id: publish
|
||||
name: Publish
|
||||
action: publish:github
|
||||
input:
|
||||
allowedHosts: ['github.com']
|
||||
description: This is ${{ parameters.name }}
|
||||
repoUrl: ${{ parameters.repoUrl }}
|
||||
+ defaultBranch: 'master'
|
||||
```
|
||||
@@ -71,6 +71,7 @@ spec:
|
||||
allowedHosts: ['github.com']
|
||||
description: This is ${{ parameters.name }}
|
||||
repoUrl: ${{ parameters.repoUrl }}
|
||||
defaultBranch: 'main'
|
||||
|
||||
- id: register
|
||||
name: Register
|
||||
|
||||
@@ -83,6 +83,7 @@ spec:
|
||||
allowedHosts: ['github.com']
|
||||
description: This is ${{ parameters.name }}
|
||||
repoUrl: ${{ parameters.repoUrl }}
|
||||
defaultBranch: 'main'
|
||||
|
||||
- id: register
|
||||
name: Register
|
||||
|
||||
@@ -48,6 +48,8 @@ spec:
|
||||
name: ${{ parameters.name }}
|
||||
|
||||
# This step publishes the contents of the working directory to GitHub.
|
||||
# If you or your organization prefer another default branch name over 'main'
|
||||
# you can change that here.
|
||||
- id: publish
|
||||
name: Publish
|
||||
action: publish:github
|
||||
@@ -55,6 +57,7 @@ spec:
|
||||
allowedHosts: ['github.com']
|
||||
description: This is ${{ parameters.name }}
|
||||
repoUrl: ${{ parameters.repoUrl }}
|
||||
defaultBranch: 'main'
|
||||
|
||||
# The final step is to register our new component in the catalog.
|
||||
- id: register
|
||||
|
||||
@@ -155,7 +155,7 @@ describe('publish:github', () => {
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: mockContext.workspacePath,
|
||||
remoteUrl: 'https://github.com/clone/url.git',
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
auth: { username: 'x-access-token', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'initial commit',
|
||||
|
||||
@@ -534,7 +534,7 @@ describe('publish:github', () => {
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: mockContext.workspacePath,
|
||||
remoteUrl: 'https://github.com/clone/url.git',
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
auth: { username: 'x-access-token', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'initial commit',
|
||||
@@ -613,7 +613,7 @@ describe('publish:github', () => {
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: mockContext.workspacePath,
|
||||
remoteUrl: 'https://github.com/clone/url.git',
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
auth: { username: 'x-access-token', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'initial commit',
|
||||
@@ -658,7 +658,7 @@ describe('publish:github', () => {
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: mockContext.workspacePath,
|
||||
remoteUrl: 'https://github.com/clone/url.git',
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
auth: { username: 'x-access-token', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'Test commit message',
|
||||
@@ -1079,7 +1079,7 @@ describe('publish:github', () => {
|
||||
);
|
||||
expect(mockContext.output).toHaveBeenCalledWith(
|
||||
'repoContentsUrl',
|
||||
'https://github.com/html/url/blob/master',
|
||||
'https://github.com/html/url/blob/main',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1131,7 +1131,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1161,7 +1161,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1190,7 +1190,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1218,7 +1218,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1307,7 +1307,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1338,7 +1338,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1372,7 +1372,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1407,7 +1407,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1443,7 +1443,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1479,7 +1479,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1516,7 +1516,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1546,7 +1546,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: {
|
||||
users: ['user'],
|
||||
@@ -1578,7 +1578,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: {
|
||||
teams: ['team'],
|
||||
@@ -1610,7 +1610,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: {
|
||||
apps: ['app'],
|
||||
@@ -1644,7 +1644,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: {
|
||||
users: ['user'],
|
||||
@@ -1680,7 +1680,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: {
|
||||
users: ['user1', 'user2'],
|
||||
@@ -1767,7 +1767,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1796,7 +1796,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
@@ -1825,7 +1825,7 @@ describe('publish:github', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repo',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
bypassPullRequestAllowances: undefined,
|
||||
requiredApprovingReviewCount: 1,
|
||||
|
||||
@@ -199,7 +199,7 @@ export function createPublishGithubAction(options: {
|
||||
requiredConversationResolution = false,
|
||||
requireLastPushApproval = false,
|
||||
repoVisibility = 'private',
|
||||
defaultBranch = 'master',
|
||||
defaultBranch = 'main',
|
||||
protectDefaultBranch = true,
|
||||
protectEnforceAdmins = true,
|
||||
deleteBranchOnMerge = false,
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ describe('github:repo:push examples', () => {
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: mockContext.workspacePath,
|
||||
remoteUrl: 'https://github.com/clone/url.git',
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
auth: { username: 'x-access-token', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'initial commit',
|
||||
|
||||
@@ -117,7 +117,7 @@ describe('github:repo:push', () => {
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: mockContext.workspacePath,
|
||||
remoteUrl: 'https://github.com/clone/url.git',
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
auth: { username: 'x-access-token', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'initial commit',
|
||||
@@ -188,7 +188,7 @@ describe('github:repo:push', () => {
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: mockContext.workspacePath,
|
||||
remoteUrl: 'https://github.com/clone/url.git',
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
auth: { username: 'x-access-token', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'initial commit',
|
||||
@@ -229,7 +229,7 @@ describe('github:repo:push', () => {
|
||||
expect(initRepoAndPush).toHaveBeenCalledWith({
|
||||
dir: mockContext.workspacePath,
|
||||
remoteUrl: 'https://github.com/clone/url.git',
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
auth: { username: 'x-access-token', password: 'tokenlols' },
|
||||
logger: mockContext.logger,
|
||||
commitMessage: 'initial commit',
|
||||
@@ -253,7 +253,7 @@ describe('github:repo:push', () => {
|
||||
);
|
||||
expect(mockContext.output).toHaveBeenCalledWith(
|
||||
'repoContentsUrl',
|
||||
'https://github.com/html/url/blob/master',
|
||||
'https://github.com/html/url/blob/main',
|
||||
);
|
||||
});
|
||||
|
||||
@@ -298,7 +298,7 @@ describe('github:repo:push', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repository',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusCheckContexts: [],
|
||||
requireBranchesToBeUpToDate: true,
|
||||
@@ -327,7 +327,7 @@ describe('github:repo:push', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repository',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusCheckContexts: ['statusCheck'],
|
||||
requireBranchesToBeUpToDate: true,
|
||||
@@ -356,7 +356,7 @@ describe('github:repo:push', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repository',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusCheckContexts: ['statusCheck'],
|
||||
requireBranchesToBeUpToDate: false,
|
||||
@@ -385,7 +385,7 @@ describe('github:repo:push', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repository',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusCheckContexts: [],
|
||||
requireBranchesToBeUpToDate: true,
|
||||
@@ -484,7 +484,7 @@ describe('github:repo:push', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repository',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusCheckContexts: [],
|
||||
requireBranchesToBeUpToDate: true,
|
||||
@@ -513,7 +513,7 @@ describe('github:repo:push', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repository',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusCheckContexts: [],
|
||||
requireBranchesToBeUpToDate: true,
|
||||
@@ -542,7 +542,7 @@ describe('github:repo:push', () => {
|
||||
client: mockOctokit,
|
||||
repoName: 'repository',
|
||||
logger: mockContext.logger,
|
||||
defaultBranch: 'master',
|
||||
defaultBranch: 'main',
|
||||
requireCodeOwnerReviews: false,
|
||||
requiredStatusCheckContexts: [],
|
||||
requireBranchesToBeUpToDate: true,
|
||||
|
||||
@@ -123,7 +123,7 @@ export function createGithubRepoPushAction(options: {
|
||||
async handler(ctx) {
|
||||
const {
|
||||
repoUrl,
|
||||
defaultBranch = 'master',
|
||||
defaultBranch = 'main',
|
||||
protectDefaultBranch = true,
|
||||
protectEnforceAdmins = true,
|
||||
gitCommitMessage = 'initial commit',
|
||||
|
||||
Reference in New Issue
Block a user