Fetch Environment Configuration

Action ID: humanitec:get-environment
NPM Package:

@humanitec/backstage-plugin-scaffolder-backend-module

Description

Fetches environment properties and required configurations for seamless integration and management.

Input Schema

No input schema defined for this action.

Output Schema

PropertyTypeDescriptionRequired
requiredany-
propertiesany-

Usage Examples

Generate environment-based config files and publish to GitHub

Fetches the Humanitec environment, renders project files with environment-specific values using fetch:template, logs required keys with debug:log, and publishes to GitHub with publish:github. Use this when you want .env and deployment config generated at scaffold time.

Copy
steps:
  - id: get-env
    action: humanitec:get-environment

  - id: scaffold-from-template
    action: fetch:template
    input:
      url: ./template
      targetPath: ./
      values:
        serviceName: ${{ parameters.serviceName }}        # e.g. "payments-service"
        environment: ${{ parameters.environment }}        # e.g. "dev"
        envProps: ${{ steps.get-env.output.properties }}  # Humanitec environment properties
        envRequired: ${{ steps.get-env.output.required }} # Humanitec required keys

  - id: log-required-keys
    action: debug:log
    input:
      message: "Humanitec required environment keys: ${{ steps.get-env.output.required }}"

  - id: publish-repo
    action: publish:github
    input:
      repoUrl: github.com?owner=acme-inc&repo=${{ parameters.serviceName }}
      defaultBranch: main
      description: "Initial scaffold for ${{ parameters.serviceName }} in ${{ parameters.environment }} environment"

Drive Helm deployment values from Humanitec environment and publish to GitLab

Fetches the Humanitec environment, injects selected properties into Helm values using fetch:template, then publishes the repo to GitLab with publish:gitlab. Use this to align cluster and namespace settings with the target environment.

Copy
steps:
  - id: get-env
    action: humanitec:get-environment

  - id: render-helm-values
    action: fetch:template
    input:
      url: ./templates/helm-app
      targetPath: ./app
      values:
        service:
          name: ${{ parameters.serviceName }}               # e.g. "inventory-api"
        deployment:
          environment: ${{ parameters.environment }}        # e.g. "staging"
          cluster: ${{ steps.get-env.output.properties.cluster }}
          namespace: ${{ steps.get-env.output.properties.namespace }}
          imageRegistry: ${{ steps.get-env.output.properties.image_registry }}
        config:
          required: ${{ steps.get-env.output.required }}

  - id: publish-to-gitlab
    action: publish:gitlab
    input:
      repoUrl: gitlab.com?owner=platform-team&repo=${{ parameters.serviceName }}
      defaultBranch: main
      description: "${{ parameters.serviceName }} scaffolded for ${{ parameters.environment }} using Humanitec environment data"