Skip to content

getlocalci/create-config

Repository files navigation

Create Config

Create a CircleCI® config with as little as 3 lines of code.

Reusable

You can use this config in any of your projects.

So you don't have to copy-paste .yml in your CircleCI® configs.

Writing Your Own

Feel free to fork this into your own Create Config repo.

You might want different settings, like different image sizes.

Or maybe you use different languages.

This has JavaScript and PHP.

Basic Usage

import { createConfig, JobNames } from "@getlocalci/create-config";

createConfig(JobNames.PhpLint, JobNames.PhpTest, JobNames.Zip);

Adding A Custom Job

import CircleCI from "@circleci/circleci-config-sdk";
import { createConfig, JobNames } from "@getlocalci/create-config";

createConfig(
  JobNames.JsLint,
  JobNames.JsTest,
  new CircleCI.Job(
    "python-test",
    new CircleCI.executors.DockerExecutor("cimg/python:3.10.7", "large"),
    [
      new CircleCI.commands.Checkout(),
      new CircleCI.commands.Run({ command: "pip install && python -m pytest" }),
    ]
  )
);

Here, you can add a CircleCI.Job with your own values.

For example, maybe you have a typical config you use for most of your repos.

But maybe a repo needs a job that no other repos need.

You can pass that CircleCI.Job as an argument to createConfig().

Thank You

Thank you, Kyle Tryon and Jaryt Bustard, for creating the CircleCI Config SDK.

This repo uses Kyle's idea of a common function in different repos.

Live Example

See this in action at .circleci/dynamic/.

This repo uses its own createConfig() to test itself 🤣