Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs prep #117

Merged
merged 2 commits into from
Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,4 @@ dist

circleci-circleci-config-sdk-0.0.0-development.tgz

dynamicConfig.yml
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@
[![npm](https://img.shields.io/npm/v/@circleci/circleci-config-sdk?logo=npm)](https://www.npmjs.com/package/@circleci/circleci-config-sdk)
[![codecov](https://codecov.io/gh/CircleCI-Public/circleci-config-sdk-ts/branch/main/graph/badge.svg?token=Z4C4RXABS7)](https://codecov.io/gh/CircleCI-Public/circleci-config-sdk-ts)
[![npm](https://img.shields.io/npm/dm/@circleci/circleci-config-sdk?logo=npm)](https://www.npmjs.com/package/@circleci/circleci-config-sdk)
![GitHub Repo stars](https://img.shields.io/github/stars/CircleCI-Public/circleci-config-sdk-ts?style=social)

Create and manage your CircleCI configuration files with JavaScript and
Create and manage your [CircleCI](https://circleci.com/) configuration files with JavaScript and
TypeScript.

## Table of Contents

- [Getting Started](#getting-started)
- [Getting Help](#getting-help)
- [CircleCI Config SDK](#circleci-config-sdk)
- [Table of Contents](#table-of-contents)
- [Getting Started](#getting-started)
- [Installation](#installation)
- [Usage](#usage)
- [Example](#example)
- [Getting Help](#getting-help)
- [Resources](#resources)
- [Contributing](#contributing)
- [Related](#related)

## Getting Started

Expand Down Expand Up @@ -139,7 +147,7 @@ Consider checking the following common resources before opening a new issue.

# Contributing

This repository welcomes community contributions! See our
This [repository](https://github.com/CircleCI-Public/circleci-config-sdk-ts) welcomes community contributions! See our
[CONTRIBUTING.md](https://github.com/CircleCI-Public/circleci-config-sdk-ts/blob/main/CONTRIBUTING.md)
for guidance on configuring your development environment and how to submit
quality pull requests.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const CircleCI = require("@circleci/circleci-config-sdk");
const dockerNode = new CircleCI.executor.DockerExecutor(
const dockerNode = new CircleCI.executors.DockerExecutor(
"docker-node",
"cimg/node:lts"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ const dynamicWorkflow = new CircleCI.Workflow("dynamic-workflow");
dynamicWorkflow.addJob(jobA);

// Conditionally add jobB
// This condition could be based on anything from the response of an API call
// to the contents of a file
if (1 == 1) {
dynamicWorkflow.addJob(jobB);
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@circleci/circleci-config-sdk": "^1.0.0"
"@circleci/circleci-config-sdk-ts": "*"
}
}
15 changes: 11 additions & 4 deletions sample/01-dynamic-workflow-javascript/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
# 01-dynamic-workflow-javascript
# 01 dynamic workflow Javascript

This example uses CircleCI's
[Dynamic Configuration](https://circleci.com/docs/2.0/dynamic-config/) feature,
which allows us to run any arbitrary config file at runtime, to compile and run
our JavaScript config file.
which allows us to run any arbitrary config file at runtime. Our `config.yml` file will be used to execute our Javascript config application, which will generate a new `dynamicConfig.yml` file that will be executed.


```mermaid
graph TD
A((fa:fa-file config.yml)) -->|dynamic config enabled| B[ fa:fa-code Generate dynamic config]
B --> C[\ fa:fa-file Execute dynamic config\]

```

The included `config.yml` file defines a workflow which will build our
JavaScript _config application_ (located in `./.circleci/dynamic`) on every push
JavaScript _config application_ (located in `.circleci/dynamic`) on every push
to our repository and then trigger a new workflow which has been generated by
the _config application_.

Expand Down