Publish To AWS CodeCommit

Action ID: aws:codecommit:publish
NPM Package:

@aws/aws-core-plugin-for-backstage-scaffolder-actions

Description

Initializes a git repository of the content in the workspace, and publishes it to AWS CodeCommit.

Input Schema

PropertyTypeDescriptionRequired
accountIdstringThe AWS account ID to create the resource.
regionstringThe AWS region to create the resource.
repositoryNamestringName of the AWS CodeCommit repository.
defaultBranchstring-
sourcePathstringPath within the workspace that will be used as the repository root. If omitted, the entire workspace will be published as the repository.
gitCommitMessagestring-
gitAuthorNamestring-
gitAuthorEmailstring-

Output Schema

PropertyTypeDescriptionRequired
arnstringARN of the repository
repositoryNamestringThe repository's name
repositoryIdstringThe ID of the repository
cloneUrlHttpstringThe URL to use for cloning the repository over HTTPS
cloneUrlSshstringThe URL to use for cloning the repository over SSH

Usage Examples

Publish the entire workspace to a new CodeCommit repository on main

Fetch a service template with fetch:template and publish the whole workspace to a new CodeCommit repository using main as the default branch.

Copy
steps:
  - id: fetch-service
    action: 'fetch:template'
    input:
      url: 'https://github.com/acme/templates/node-express-service'
      targetPath: '.'
      values:
        serviceId: ${{ parameters.serviceId }}
        owner: ${{ parameters.owner }}
        port: 8080

  - id: publish-codecommit
    action: 'aws:codecommit:publish'
    input:
      repositoryName: 'orders-service'
      defaultBranch: 'main'
      gitCommitMessage: 'chore: initial commit for orders-service'
      gitAuthorName: 'Backstage Scaffolder'
      gitAuthorEmail: '[email protected]'

Publish only a subdirectory to CodeCommit using develop as the default branch

Use fetch:template to create a monorepo structure, then publish only the API service subfolder to CodeCommit with develop as the default branch.

Copy
steps:
  - id: fetch-monorepo
    action: 'fetch:template'
    input:
      url: 'https://github.com/acme/templates/monorepo-skeleton'
      targetPath: '.'
      values:
        system: ${{ parameters.system }}
        apiServiceId: ${{ parameters.apiServiceId }}
        uiServiceId: ${{ parameters.uiServiceId }}

  - id: publish-api
    action: 'aws:codecommit:publish'
    input:
      repositoryName: 'inventory-api'
      defaultBranch: 'develop'
      sourcePath: './services/api'
      region: 'eu-west-1'
      gitCommitMessage: 'feat: scaffold inventory API service'
      gitAuthorName: ${{ parameters.authorName }}
      gitAuthorEmail: ${{ parameters.authorEmail }}

Publish to a specific AWS account and region

Target a specific AWS account and region for repository creation. This is useful in multi account setups where environments are isolated.

Copy
steps:
  - id: fetch-service
    action: 'fetch:template'
    input:
      url: 'https://github.com/acme/templates/python-fastapi-service'
      targetPath: '.'
      values:
        serviceId: ${{ parameters.serviceId }}
        description: ${{ parameters.description }}

  - id: publish-to-account
    action: 'aws:codecommit:publish'
    input:
      accountId: ${{ parameters.awsAccountId }}
      region: ${{ parameters.awsRegion }}
      repositoryName: ${{ parameters.repoName }}
      defaultBranch: 'trunk'
      gitCommitMessage: 'chore: initial import for ${{ parameters.repoName }}'
      gitAuthorName: 'Service Factory'
      gitAuthorEmail: '[email protected]'

Use user provided author info and custom commit message

Let users supply commit author details and a custom message, then publish to CodeCommit. This keeps audit information consistent with your internal standards.

Copy
steps:
  - id: fetch-template
    action: 'fetch:template'
    input:
      url: 'https://github.com/acme/templates/go-chi-service'
      targetPath: '.'
      values:
        serviceId: ${{ parameters.serviceId }}
        owner: ${{ parameters.owner }}

  - id: publish-with-author
    action: 'aws:codecommit:publish'
    input:
      repositoryName: ${{ parameters.serviceId }}
      defaultBranch: ${{ parameters.defaultBranch }}
      gitCommitMessage: ${{ parameters.initialCommitMessage }}
      gitAuthorName: ${{ parameters.authorName }}
      gitAuthorEmail: ${{ parameters.authorEmail }}

Build the repository name from multiple parameters and set a regional target

Compose the repository name from system and service identifiers, publish a specific folder, and target a regional account setup.

Copy
steps:
  - id: fetch-multi
    action: 'fetch:template'
    input:
      url: 'https://github.com/acme/templates/kotlin-spring-service'
      targetPath: '.'
      values:
        system: ${{ parameters.system }}
        serviceId: ${{ parameters.service }}
        owner: ${{ parameters.owner }}

  - id: publish-composed-name
    action: 'aws:codecommit:publish'
    input:
      accountId: '555555555555'
      region: 'ap-southeast-2'
      repositoryName: '${{ parameters.system }}-${{ parameters.service }}'
      defaultBranch: 'main'
      sourcePath: './service'
      gitCommitMessage: 'init: scaffold ${{ parameters.system }}-${{ parameters.service }}'
      gitAuthorName: 'Platform Engineering'
      gitAuthorEmail: '[email protected]'