diff --git a/.changeset/bright-lions-camp.md b/.changeset/bright-lions-camp.md new file mode 100644 index 0000000000..ccb812b01e --- /dev/null +++ b/.changeset/bright-lions-camp.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend': patch +--- + +Allow custom directory to be specified for github publish action diff --git a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts index 4f9b6038a1..5979136488 100644 --- a/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/actions/builtin/publish/github.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - +import { resolve as resolvePath } from 'path'; import { InputError } from '@backstage/errors'; import { GithubCredentialsProvider, @@ -40,6 +40,7 @@ export function createPublishGithubAction(options: { repoUrl: string; description?: string; access?: string; + repoPath?: string; repoVisibility: 'private' | 'internal' | 'public'; }>({ id: 'publish:github', @@ -67,6 +68,10 @@ export function createPublishGithubAction(options: { type: 'string', enum: ['private', 'public', 'internal'], }, + repoPath: { + title: 'Repository Path', + type: 'string', + }, }, }, output: { @@ -158,9 +163,12 @@ export function createPublishGithubAction(options: { const remoteUrl = data.clone_url; const repoContentsUrl = `${data.html_url}/blob/master`; + const outputPath = ctx.input.repoPath + ? resolvePath(ctx.workspacePath, ctx.input.repoPath) + : ctx.workspacePath; await initRepoAndPush({ - dir: ctx.workspacePath, + dir: outputPath, remoteUrl, auth: { username: 'x-access-token',