GithubHelp home page GithubHelp logo

woensug-choi / circleci-config-sdk-ts Goto Github PK

View Code? Open in Web Editor NEW

This project forked from circleci-public/circleci-config-sdk-ts

0.0 0.0 0.0 1.55 MB

Generate CircleCI Configuration YAML from JavaScript or TypeScript. Use Dynamic Configuration and the Config SDK together for live generative config.

Home Page: https://circleci-public.github.io/circleci-config-sdk-ts/

License: Apache License 2.0

Shell 0.50% JavaScript 0.43% TypeScript 99.07%

circleci-config-sdk-ts's Introduction

CircleCI Config SDK

GitHub CircleCI npm codecov npm GitHub Repo stars

Create and manage your CircleCI configuration files with JavaScript and TypeScript.

Table of Contents

Getting Started

๐Ÿ“– Getting Started Wiki

๐Ÿ“– SDK API Docs

๐Ÿ’ป Examples


Installation

Using npm:

$ npm i @circleci/circleci-config-sdk

Using yarn:

$ yarn add @circleci/circleci-config-sdk

Usage

In Browser:

import CircleCI from '@circleci/circleci-config-sdk';

In Node.js:

const CircleCI = require('@circleci/circleci-config-sdk');

Example

Generate a CircleCI config using TypeScript/Javascript, properly typed for full IntelliSense support.

const CircleCI = require('@circleci/circleci-config-sdk');
// Instantiate new Config
const myConfig = new CircleCI.Config();
// Create new Workflow
const myWorkflow = new CircleCI.Workflow('myWorkflow');
myConfig.addWorkflow(myWorkflow);

// Create an executor instance
// Executors are used directly in jobs
// and do not need to be added to the config separately
const nodeExecutor = new CircleCI.executors.DockerExecutor('cimg/node:lts');

// Create Job and add it to the config
const nodeTestJob = new CircleCI.Job('node-test', nodeExecutor);
myConfig.addJob(nodeTestJob);

// Add steps to job
nodeTestJob
  .addStep(new CircleCI.commands.Checkout())
  .addStep(
    new CircleCI.commands.Run({
      command: 'npm install',
      name: 'NPM Install',
    }),
  )
  .addStep(
    new CircleCI.commands.Run({
      command: 'npm run test',
      name: 'Run tests',
    }),
  );

// Add Jobs to Workflow
myWorkflow.addJob(nodeTestJob);

// The `stringify()` function on `CircleCI.Config` will return the CircleCI YAML equivalent.
const MyYamlConfig = myConfig.stringify();

// Save the config to a file in Node.js or the browser. Note, use in the browser requires user interaction.
myConfig.writeFile('config.yml');

MyYamlConfig will hold the following string (A valid CircleCI Config).

version: 2.1
setup: false
jobs:
  node-test:
    docker:
      - image: cimg/node:lts
    resource_class: medium
    steps:
      - checkout: {}
      - run:
          command: npm install
          name: NPM Install
      - run:
          command: npm run test
          name: Run tests
workflows:
  myWorkflow:
    jobs:
      - node-test: {}

Getting Help

This open-source project utilized GitHub issues and project boards to manage requests and support.

If you can not find an answer to your question in an existing issue, you may open a new issue with the appropriate template. Issues are the best way for the CircleCI team and the open-source community to track and interact with your questions.

Resources

Consider checking the following common resources before opening a new issue.

Contributing

This repository welcomes community contributions! See our CONTRIBUTING.md for guidance on configuring your development environment and how to submit quality pull requests.

Related

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.