Skip to content

Commit 00e9e81

Browse files
authored
Document how to use FlowCrafter in README (#28)
An initial pass at some documentation has been done in the project's README. It describes how to create templates, initialize FlowCrafter in a project, and then use it to generate workflows.
1 parent 5c74cf5 commit 00e9e81

File tree

1 file changed

+120
-0
lines changed

1 file changed

+120
-0
lines changed

README.md

+120
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,126 @@
33
FlowCrafter is a command-line tool to create and manage workflows for
44
[GitHub Actions].
55

6+
## Installation
7+
8+
FlowCrafter can be installed using `cargo`. Running the following command will
9+
download the latest version of FlowCrafter, compile it, and make it available as
10+
a command-line tool.
11+
12+
```shell
13+
cargo install flowcrafter
14+
```
15+
16+
After the installation, `flowcrafter` is available as a command in the terminal:
17+
18+
```shell
19+
flowcrafter --help
20+
```
21+
22+
## Usage
23+
24+
Using FlowCrafter consists of three different steps:
25+
26+
1. [Creating templates for workflows and jobs](#create-templates)
27+
2. [Initializing FlowCrafter in a repository](#initialize-flowcrafter)
28+
3. [Creating and updating workflows](#create-a-workflow)
29+
30+
### Create Templates
31+
32+
FlowCrafter uses templates stored on GitHub to create workflows and jobs. These
33+
are YAML files that follow a few conventions:
34+
35+
- The repository contains a folder for each workflow (e.g. `rust`).
36+
- Each workflow folder contains a file called `workflow.yml` that defines the
37+
workflow (e.g. `rust/workflow.yml`).
38+
- Job templates are stored in the same folder as the workflow file (e.g.
39+
`rust/lint.yml`).
40+
41+
#### Workflow
42+
43+
The workflow template sets the top-level configuration for the workflow. It can
44+
also contain a list of jobs that should always be part of the workflow.
45+
46+
The workflow template is always named `workflow.yml`.
47+
48+
```yaml
49+
---
50+
name: Rust
51+
52+
"on":
53+
push:
54+
branches:
55+
- main
56+
pull_request:
57+
58+
jobs:
59+
run-always:
60+
name: Always include this job
61+
runs-on: ubuntu-latest
62+
63+
steps:
64+
- run: echo "This will always be included"
65+
```
66+
67+
#### Jobs
68+
69+
Jobs are defined in individual YAML files within the workflow folder. Each
70+
represents a single job that can be included in a workflow.
71+
72+
```yaml
73+
style:
74+
name: Check style
75+
runs-on: ubuntu-latest
76+
77+
steps:
78+
- name: Checkout code
79+
uses: actions/checkout@v3
80+
81+
- name: Run Rustfmt
82+
run: cargo fmt --all -- --check
83+
```
84+
85+
### Initialize FlowCrafter
86+
87+
FlowCrafter manages the workflows for a repository on GitHub. After cloning the
88+
repository to your local machine, open a terminal, change into its directory,
89+
and then generate a configuration file for FlowCrafter:
90+
91+
```shell
92+
flowcrafter init -r <owner>/<repo>
93+
```
94+
95+
This will create a file called `.flowcrafter.yml` in the `.github` directory and
96+
configure the repository `owner/repo` as the source for workflow and job
97+
templates.
98+
99+
### Create a Workflow
100+
101+
With FlowCrafter initialized and templates on GitHub, you can now create a
102+
workflow with FlowCrafter:
103+
104+
```shell
105+
flowcrafter create -w <workflow> -j <job> -j <job>
106+
```
107+
108+
For example, given a repository with the following templates:
109+
110+
```text
111+
rust
112+
├── lint.yml
113+
├── test.yml
114+
└── workflow.yml
115+
```
116+
117+
You can create a workflow for Rust with the following command:
118+
119+
```shell
120+
flowcrafter create -w rust -j lint -j test
121+
```
122+
123+
This will create the file `.github/workflows/rust.yml` and merge `workflow.yml`
124+
and the two jobs `lint.yml` and `test.yml` into it.
125+
6126
## License
7127

8128
Licensed under either of

0 commit comments

Comments
 (0)