@voiceflow/circleci-config-sdk-orb-import
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Orb Import for CircleCI Config SDK

NPM Version License

This package allows you to import and use external orbs with the CircleCI Config SDK.

Installation

Using npm:

   npm install @voiceflow/circleci-config-sdk-orb-import 

Using yarn:

    yarn add @voiceflow/circleci-config-sdk-orb-import 

Usage

This package provides a single function, importOrb, to fetch the manifest for an external orb and return them as an OrbImport compatible with the CircleCI Config SDK.

import * as CircleCI from "@circleci/circleci-config-sdk";
import { importOrb } from "circleci-config-sdk-orb-import";

// Instantiate a new Config
const config = new CircleCI.Config();

// Use the importOrb function to fetch a given external orb
// This is equivalent to putting `node: circleci/node@5.0.3` in the `.circleci/config.yml` file
const node = await importOrb({
  alias: "node",
  namespace: "circleci",
  orb: "node",
  version: "5.0.3",
});

// Add the imported orb to the generated config
config.importOrb(node);

// Use an executor from the orb in your jobs
const exampleExecutor = new CircleCI.reusable.ReusedExecutor(
  node.executors["default"],
  {
    tag: "16",
  }
);

const exampleJob = new CircleCI.Job("install-node", exampleExecutor, [
  new CircleCI.commands.Checkout(),
  // Use a command from the orb in your jobs
  new CircleCI.reusable.ReusedCommand(node.commands["install-packages"], {
    "check-cache": "always",
    "pkg-manager": "yarn-berry",
  }),
]);
config.addJob(exampleJob);

const exampleWorkflow = new CircleCI.Workflow("example", [
  exampleJob,
  // Use a job from the orb in your workflows
  new CircleCI.workflow.WorkflowJob(node.jobs["run"], {
    "yarn-run": "build",
  }),
]);
config.addWorkflow(exampleWorkflow);

The above config generates the following YAML config:

version: 2.1
setup: false
jobs:
  install-node:
    executor:
      name: node/default
      tag: "16"
    steps:
      - checkout
      - node/install-packages:
          check-cache: always
          pkg-manager: yarn-berry
workflows:
  example:
    jobs:
      - install-node
      - node/run:
          yarn-run: build
orbs:
  node: circleci/node@5.0.3

Compatibility

This version has been tested with version 0.10.1 of the CircleCI Config SDK. Compatibility with other versions cannot be guaranteed.

License

Licensed under ISC

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.2.0
    361
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.2.0
    361
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i @voiceflow/circleci-config-sdk-orb-import

Weekly Downloads

361

Version

0.2.0

License

ISC

Unpacked Size

12.6 kB

Total Files

13

Last publish

Collaborators

  • ose-voiceflow
  • theprof
  • bhuvana.adur.kannan
  • abuyak
  • e_vandenberg
  • ninabondar
  • yoyotruly
  • matthewnaik
  • edison-vflow
  • shelone.grantwatson
  • zhilight
  • amandasteinhauer
  • pmvrmc
  • filipemerker
  • viniciusdacal
  • trs
  • matheuspoleza
  • denyslinkov
  • andrewlawrence
  • tylerhhan
  • effervescentia
  • josh_vf
  • voiceflow-gallagan
  • z4o4z
  • xavidop
  • vf-serviceaccount