From b2ece20e2e2ad70bb6d74edeb83a747d7f292a7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=B6derlund?= Date: Sat, 5 Apr 2025 21:49:03 +0200 Subject: [PATCH 1/7] Updated github tests to reflect that the default branch is expected to be "main" for new repos that get created. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Söderlund --- .../src/actions/github.examples.test.ts | 2 +- .../src/actions/github.test.ts | 46 +++++++++---------- .../actions/githubRepoPush.examples.test.ts | 2 +- .../src/actions/githubRepoPush.test.ts | 22 ++++----- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/plugins/scaffolder-backend-module-github/src/actions/github.examples.test.ts b/plugins/scaffolder-backend-module-github/src/actions/github.examples.test.ts index 6a6c6daf13..3c7f27f572 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/github.examples.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/github.examples.test.ts @@ -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', diff --git a/plugins/scaffolder-backend-module-github/src/actions/github.test.ts b/plugins/scaffolder-backend-module-github/src/actions/github.test.ts index 2f629622d0..24bb229d77 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/github.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/github.test.ts @@ -491,7 +491,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', @@ -570,7 +570,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', @@ -615,7 +615,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', @@ -1036,7 +1036,7 @@ describe('publish:github', () => { ); expect(mockContext.output).toHaveBeenCalledWith( 'repoContentsUrl', - 'https://github.com/html/url/blob/master', + 'https://github.com/html/url/blob/main', ); }); @@ -1088,7 +1088,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1118,7 +1118,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1147,7 +1147,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1175,7 +1175,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1264,7 +1264,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1295,7 +1295,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1329,7 +1329,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1364,7 +1364,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1400,7 +1400,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1436,7 +1436,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1473,7 +1473,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1503,7 +1503,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: { users: ['user'], @@ -1535,7 +1535,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: { teams: ['team'], @@ -1567,7 +1567,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: { apps: ['app'], @@ -1601,7 +1601,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: { users: ['user'], @@ -1637,7 +1637,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: { users: ['user1', 'user2'], @@ -1724,7 +1724,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1753,7 +1753,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, @@ -1782,7 +1782,7 @@ describe('publish:github', () => { client: mockOctokit, repoName: 'repo', logger: mockContext.logger, - defaultBranch: 'master', + defaultBranch: 'main', requireCodeOwnerReviews: false, bypassPullRequestAllowances: undefined, requiredApprovingReviewCount: 1, diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.examples.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.examples.test.ts index e9cc9d95de..6570ce8f4b 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.examples.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.examples.test.ts @@ -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', diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.test.ts b/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.test.ts index 7fdf2e1af6..a3b2478ce6 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.test.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.test.ts @@ -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, From 7bbd08b3e8fbdf5036e90cd2a507def410ba9535 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=B6derlund?= Date: Sat, 5 Apr 2025 21:50:14 +0200 Subject: [PATCH 2/7] Changed value of defaultBranch from 'master' to 'main'. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Söderlund --- plugins/scaffolder-backend-module-github/src/actions/github.ts | 2 +- .../src/actions/githubRepoPush.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/scaffolder-backend-module-github/src/actions/github.ts b/plugins/scaffolder-backend-module-github/src/actions/github.ts index 02b1fbbe32..1e62d914e0 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/github.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/github.ts @@ -197,7 +197,7 @@ export function createPublishGithubAction(options: { requiredConversationResolution = false, requireLastPushApproval = false, repoVisibility = 'private', - defaultBranch = 'master', + defaultBranch = 'main', protectDefaultBranch = true, protectEnforceAdmins = true, deleteBranchOnMerge = false, diff --git a/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.ts b/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.ts index 1923a0bd35..f74ce33865 100644 --- a/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.ts +++ b/plugins/scaffolder-backend-module-github/src/actions/githubRepoPush.ts @@ -123,7 +123,7 @@ export function createGithubRepoPushAction(options: { async handler(ctx) { const { repoUrl, - defaultBranch = 'master', + defaultBranch = 'main', protectDefaultBranch = true, protectEnforceAdmins = true, gitCommitMessage = 'initial commit', From c0bb4b9c923c0d605a773f1b97be8ceaaa2bf916 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=B6derlund?= Date: Sat, 5 Apr 2025 22:02:47 +0200 Subject: [PATCH 3/7] Updated the example template "create-app" to include defaultBranch: 'main' when publishing to github MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Söderlund --- .../templates/default-app/examples/template/template.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/create-app/templates/default-app/examples/template/template.yaml b/packages/create-app/templates/default-app/examples/template/template.yaml index 33f262b49c..cfba98e878 100644 --- a/packages/create-app/templates/default-app/examples/template/template.yaml +++ b/packages/create-app/templates/default-app/examples/template/template.yaml @@ -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 From 6febfdb2b74db12a9b8c27c2af530d47359599a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=B6derlund?= Date: Sat, 5 Apr 2025 22:04:47 +0200 Subject: [PATCH 4/7] Update the documentation to reflect that defaultBranch can be set when publishing to github MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Söderlund --- docs/features/software-templates/adding-templates.md | 1 + docs/features/software-templates/writing-templates.md | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/features/software-templates/adding-templates.md b/docs/features/software-templates/adding-templates.md index 083516192c..674ee8788b 100644 --- a/docs/features/software-templates/adding-templates.md +++ b/docs/features/software-templates/adding-templates.md @@ -71,6 +71,7 @@ spec: allowedHosts: ['github.com'] description: This is ${{ parameters.name }} repoUrl: ${{ parameters.repoUrl }} + defaultBranch: 'main' - id: register name: Register diff --git a/docs/features/software-templates/writing-templates.md b/docs/features/software-templates/writing-templates.md index bc2847a81b..4abe8f1eb0 100644 --- a/docs/features/software-templates/writing-templates.md +++ b/docs/features/software-templates/writing-templates.md @@ -83,6 +83,7 @@ spec: allowedHosts: ['github.com'] description: This is ${{ parameters.name }} repoUrl: ${{ parameters.repoUrl }} + defaultBranch: 'main' - id: register name: Register From c761cf5b3a20ef383825fc3d52f99df246a6961f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=B6derlund?= Date: Sat, 5 Apr 2025 22:17:04 +0200 Subject: [PATCH 5/7] Added changeset with instructions on how to not be affected by this change in existing templates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Söderlund --- .changeset/smooth-moons-bake.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 .changeset/smooth-moons-bake.md diff --git a/.changeset/smooth-moons-bake.md b/.changeset/smooth-moons-bake.md new file mode 100644 index 0000000000..10bc7787aa --- /dev/null +++ b/.changeset/smooth-moons-bake.md @@ -0,0 +1,21 @@ +--- +'@backstage/plugin-scaffolder-backend-module-github': minor +'@backstage/create-app': minor +--- + +**BREAKING** The `publish:github` scaffolder action defaults to initializing a branche 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' +``` From 2e32407e4b9f5b4591b8a65be8ac6d7a6506cd9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20S=C3=B6derlund?= Date: Sat, 5 Apr 2025 22:23:40 +0200 Subject: [PATCH 6/7] fixed language in change set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: David Söderlund --- .changeset/smooth-moons-bake.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/smooth-moons-bake.md b/.changeset/smooth-moons-bake.md index 10bc7787aa..19b5e502bb 100644 --- a/.changeset/smooth-moons-bake.md +++ b/.changeset/smooth-moons-bake.md @@ -3,7 +3,7 @@ '@backstage/create-app': minor --- -**BREAKING** The `publish:github` scaffolder action defaults to initializing a branche named "main" instead of "master" when creating new repositories. +**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. From b62e93df21aaeacb2237ef00efec2679d11023dc Mon Sep 17 00:00:00 2001 From: Ben Lambert Date: Tue, 15 Apr 2025 11:44:43 +0200 Subject: [PATCH 7/7] Update create-app version to patch Signed-off-by: benjdlambert --- .changeset/smooth-moons-bake.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/smooth-moons-bake.md b/.changeset/smooth-moons-bake.md index 19b5e502bb..e9c0cf7ba7 100644 --- a/.changeset/smooth-moons-bake.md +++ b/.changeset/smooth-moons-bake.md @@ -1,6 +1,6 @@ --- '@backstage/plugin-scaffolder-backend-module-github': minor -'@backstage/create-app': 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.