Publish Repository To GitLab

Action ID: harmonix:createRepoAccessToken:gitlab
NPM Package:

@aws/plugin-scaffolder-backend-aws-apps-for-backstage

Description

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

Input Schema

PropertyTypeDescriptionRequired
regionstring-
repoUrlstring-
projectIdnumber-
secretArnstring-

Output Schema

No output schema defined for this action.

Usage Examples

Publish workspace contents to a new GitLab.com repo using SSH

Initializes the workspace as a Git repo and pushes it to a GitLab.com project using an SSH remote. Use this when your runners have SSH access and your GitLab access token is stored in AWS Secrets Manager.

Copy
steps:
  - id: fetch-base
    action: fetch:template
    input:
      url: ./skeleton
      values:
        name: ${{ parameters.name }}
        owner: acme

  - id: publish-to-gitlab
    action: harmonix:createRepoAccessToken:gitlab
    input:
      repoUrl: git@gitlab.com:acme/checkout-service.git
      projectId: 48299312
      secretArn: arn:aws:secretsmanager:us-east-1:123456789012:secret:gitlab/pat-main-abc123

  - id: register-in-catalog
    action: catalog:register
    input:
      catalogInfoUrl: https://gitlab.com/acme/checkout-service/-/raw/main/catalog-info.yaml

Publish to a self-managed GitLab instance with a regional secret

Pushes to a self-managed GitLab server using an SSH URL and reads the GitLab token from a Secrets Manager secret in eu-west-1. Use this when your GitLab is hosted on-prem or in a private network.

Copy
steps:
  - id: fetch
    action: fetch:template
    input:
      url: ./templates/service
      values:
        name: ${{ parameters.serviceName }}
        owner: platform

  - id: publish-self-managed
    action: harmonix:createRepoAccessToken:gitlab
    input:
      repoUrl: git@gitlab.internal:platform/api-service.git
      projectId: 903301
      secretArn: arn:aws:secretsmanager:eu-west-1:222233334444:secret:gitlab/pat-ci-wxyz
      region: eu-west-1

  - id: register
    action: catalog:register
    input:
      catalogInfoUrl: https://gitlab.internal/platform/api-service/-/raw/main/catalog-info.yaml

Parameterized subgroup repo using template inputs

Builds the repo URL from template parameters and uses projectId provided by the user. Use this to support subgroups and different owners in one template.

Copy
steps:
  - id: prepare
    action: fetch:template
    input:
      url: ./skeleton
      values:
        name: ${{ parameters.repo }}
        owner: ${{ parameters.owner }}

  - id: publish-parameterized
    action: harmonix:createRepoAccessToken:gitlab
    input:
      repoUrl: git@gitlab.com:${{ parameters.owner }}/${{ parameters.repo }}.git
      projectId: ${{ parameters.projectId }}
      secretArn: ${{ parameters.secretArn }}

  - id: register
    action: catalog:register
    input:
      catalogInfoUrl: https://gitlab.com/${{ parameters.owner }}/${{ parameters.repo }}/-/raw/main/catalog-info.yaml

Publish using HTTPS remote and a repo in a nested group

Initializes the repository and pushes via HTTPS to a project under a nested group. Use this when SSH is not available and your runners authenticate with a GitLab token.

Copy
steps:
  - id: fetch-template
    action: fetch:template
    input:
      url: ./templates/lib
      values:
        name: data-pipeline
        owner: acme/infrastructure

  - id: publish-https
    action: harmonix:createRepoAccessToken:gitlab
    input:
      repoUrl: https://gitlab.com/acme/infrastructure/data-pipeline.git
      projectId: 43933811
      secretArn: arn:aws:secretsmanager:us-west-2:123456789012:secret:gitlab/pat-publisher-1234
      region: us-west-2

  - id: register
    action: catalog:register
    input:
      catalogInfoUrl: https://gitlab.com/acme/infrastructure/data-pipeline/-/raw/main/catalog-info.yaml

Publish to an on-prem GitLab over nonstandard SSH port

Uses an SSH URL with an explicit port and a token stored in ap-southeast-2. Use this when your GitLab SSH service runs on a custom port.

Copy
steps:
  - id: fetch
    action: fetch:template
    input:
      url: ./base
      values:
        name: ops-tools
        owner: team

  - id: publish-custom-port
    action: harmonix:createRepoAccessToken:gitlab
    input:
      repoUrl: ssh://git@gitlab.ops.local:2222/team/ops-tools.git
      projectId: ${{ parameters.existingProjectId }}
      secretArn: arn:aws:secretsmanager:ap-southeast-2:999900001111:secret:gitlab/pat-rotated-efgh
      region: ap-southeast-2

  - id: register
    action: catalog:register
    input:
      catalogInfoUrl: https://gitlab.ops.local/team/ops-tools/-/raw/main/catalog-info.yaml

References to other actions