@gabtec/backstage-action-var-set

1.0.5 • Public • Published

Gabtec's Backstage Custom Template Action

gabtec:var:set

This action will allow us to set template local variables, re-usable along the template

Usage

# inside a template.yaml file, on steps block:
steps:
  # 1. DECLARE a local variable using my custom action
  - id: setlocals
    action: gabtec:var:set
    input:
      key1: value1
      key2: value2
  # 2. USE it
  - id: log-message
    action: debug:log
    input:
      myLocalVar1: "${{ steps.setlocals.output.vars.key1 }}"
      myLocalVar2: "${{ steps.setlocals.output.vars.key2 }}"

Installation

# install it as a dependecie
yarn --cwd packages/backend add @gabtec/backstage-action-var-set@1.0.2
yarn --cwd packages/backend add @backstage/integration

Edit "packages/backend/src/plugins/scaffolder.ts"

Register the new custom action

import {
  createRouter,
  createBuiltinActions, // <--------------- add this
} from "@backstage/plugin-scaffolder-backend";
import {
  ScmIntegrations, // <<------------------- add this
} from "@backstage/integration";
import { createSetLocalVarsAction } from "@gabtec/backstage-action-var-set";

// (...)

// we have to fetch all integrations, in order to merge our new action
const integrations = ScmIntegrations.fromConfig(env.config);

// now add it to BS, but it will override existing ones, so we have to include them also
const builtInActions = createBuiltinActions({
  integrations,
  catalogClient,
  config: env.config,
  reader: env.reader,
});

// merge existing ones with our custom one
const actions = [...builtInActions, createSetLocalVarsAction()];

return await createRouter({
  actions, // <<------------------- add them
  logger: env.logger,
  // (...)
});

Package Sidebar

Install

npm i @gabtec/backstage-action-var-set

Weekly Downloads

2

Version

1.0.5

License

MIT

Unpacked Size

3.38 kB

Total Files

3

Last publish

Collaborators

  • gabtec-org