Skip to content

Commit 0ff3407

Browse files
rachmarigracepark
andauthored
Add pipeline documentation (#36522)
Co-authored-by: Grace Park <gracepark@github.com>
1 parent a8df6bc commit 0ff3407

File tree

13 files changed

+231
-56
lines changed

13 files changed

+231
-56
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,4 @@ jobs:
112112
channel: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }}
113113
bot-token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }}
114114
color: failure
115-
text: The last Sync OpenAPI schema run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/openapi-decorate.yml
115+
text: The last Sync OpenAPI schema run for ${{github.repository}} failed. See https://github.com/${{github.repository}}/actions/workflows/sync-openapi.yml

src/automated-pipelines/README.md

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,51 @@
11
# Automated pipelines
22

3-
Our automated pipelines directory contains code shared by our automated pipelines, including REST, GraphQL, Webhooks, CodeQL, and GitHub Apps.
3+
Our automated pipelines directory contains code shared by our automated pipelines, including REST, GraphQL, Webhooks, CodeQL CLI, and GitHub Apps.
44

55
## What is automated pipelines
66

7-
An automated pipeline adds automatically generated content to docs.github.com
7+
An automated pipeline consumes data from an external source that is used to create content for docs.github.com. An automated pipeline does not automate documentation that is created by our content writing team. For example, if a writer creates a structured data file like YAML or JSON that lives in the `docs-internal` repo, using that data to create a page does not create an automated pipeline.
8+
9+
Automated pages allow for manually created content to be prepended to the automated content, but do not allow for manually created content to be appended or interspersed within automated content. Manually created content (that is prepended to automated content) lives in the Markdown file associated with the automated page, along with the article's frontmatter metadata.
10+
11+
## What automation pipelines are available
12+
13+
- [CodeQL CLI](../codeql-cli/README.md)
14+
- [GitHub Apps](../github-apps/README.md)
15+
- [GraphQL](../graphql/README.md)
16+
- [REST](../rest/README.md)
17+
- [Webhooks](../webhooks/README.md)
818

919
## How does it work
1020

21+
We currently have two patterns that we used to create automated pipelines:
22+
- REST, Webhooks, GitHub Apps, and GraphQL pipelines consume external structured data and transform that data into a JSON file that is used to create content for a page on docs.github.com. Typically, data files are a 1:1 mapping to a specific page on docs.github.com.
23+
- The CodeQL CLI pipeline takes an unstructured ReStructuredText file and transforms it directly into a Markdown file with frontmatter, that uses the same authoring format as the rest of the docs.
24+
25+
## Creating a new pipeline
26+
27+
Each pipeline should be evaluated individually to determine the best architecture for simplicity, maintainability, and requirements.
28+
For example:
29+
- Is the content being displayed basic Markdown content? For example, does the content avoid using complex tables and interactive elements? If so, then writing the Markdown content directly and avoiding the need to create a structured data file that requires a React component may be the best approach. This was the case for the CodeQL CLI pipeline. One caveat to think about before writing Markdown directly is whether the content will need liquid versioning. The current pipeline that writes Markdown directly does not need to use liquid versioning. Liquid versioning which would increase the complexity quite a bit. All of the Markdown content in each article that is generated from the CodeQL CLI pipeline applies to all versions listed in the `versions` frontmatter property, simplifying the Markdown generation process.
30+
- Is the page interactive like the REST and Webhooks pages? If so, then the data will likely need to be structured data. In that case, a new React component may be needed to display the data.
31+
32+
### Initial migrations
33+
34+
When creating a new pipeline, the source data that is being consumed may not have all of the necessary data needed to create the page. Oftentimes, source data does not contain descriptions and prose that our content writers have crafted to describe properties or concepts. In this case, it's common to need to scrape data from our docs and merge it into a new field in the structured data file that we intend to consume. When creating a new pipeline, you'll need to work with the team that owns the source data to create a plan for adding any additional properties and agreeing on a format that will work best for both teams.
35+
36+
### What to include in a new pipeline
37+
38+
- Create a new directory in the `src` directory with the name of the pipeline. For example, `src/codeql-cli`.
39+
- Add a README.md file that describes the pipeline and how to use it. This should include any dependencies, how to run the pipeline, and any other information that is needed to use the pipeline. It's strongly recommended to include a diagram showing the overall flow of the pipeline.
40+
- Each pipeline typically requires a workflow to allow scheduling or manually running the pipeline. The workflow should be placed in the `.github/workflows` directory and named `sync-<pipeline-name>.js`. Each workflow typically requires adding a manual run option and an input parameter to specify the source repo's branch to use.
41+
- Each pipeline will need a `scripts` directory with (at minimum) a `scripts/sync.js` file to run the pipeline.
42+
- If the pipeline will contain structured data, you will need to add a `src/<pipeline-name>/data` directory. The files inside the `data` directory are typically organized by version (e.g., `src/webhooks/data/fpt/*`).
43+
- Pipelines typically have tests specific to the pipeline that are placed in the `src/<pipeline-name>/tests` directory. There is no need to add tests that render the page because all autogenerated pages are tested in `src/automated-pipelines/tests/rendering.js`.
44+
- If the pipeline uses a Next.js page component (e.g., `pages/**/*.tsx`), ensure there is a test that fails if that page component is moved or deleted.
45+
1146
## How to get help
47+
48+
Slack: `#docs-engineering`
49+
Repo: `github/docs-engineering`
50+
51+
If you have a question about automation pipelines, you can ask in the `#docs-engineering` Slack channel. If you notice a problem with one of the automation pipelines, you can open an issue in the `github/docs-engineering` repository.

src/codeql-cli/README.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,48 @@
1-
# CodeQL CLI
1+
# CodeQL CLI pipeline
22

3-
Our CodeQL CLI pipeline adds automated documentation on docs.github.com.
3+
Our CodeQL CLI pipeline creates autogenerated documentation for docs.github.com from the source code used to build the [CodeQL CLI](https://docs.github.com/en/code-security/codeql-cli/using-the-codeql-cli/about-the-codeql-cli).
44

5-
## What is CodeQL CLI
6-
7-
CodeQL is an intelligent code scanning service that checks for security issues in code.
5+
The pipeline is used to generate Markdown files that create article pages on the docs.github.com site.
86

97
## How does it work
108

9+
![A flow chart describing how the automation pipeline for CodeQL CLI generates documentation](./codeql-cli-pipeline-flowchart.png)
10+
11+
A [workflow](.github/workflows/sync-codeql-cli.yml) is used to trigger the automation of the CodeQL CLI documentation. The workflow is manually triggered by a member of the GitHub Docs team approximately every two weeks to align to releases of the CodeQL CLI. The workflow takes an input parameter that specifies the branch to pull the source files from in the semmle-code repo. If the branch input is omitted, the workflow will default to the `main` branch.
12+
13+
The workflow runs the `src/codeql-cli/scripts/sync.js` script, which generates Markdown files under `content/code-security/codeql-cli/codeql-cli-manual`.
14+
15+
The workflow automatically creates a new pull request with the changes and the label `codeql-cli-pipeline`.
16+
17+
## Local development
18+
19+
To run the CodeQL CLI pipeline locally:
20+
21+
1. Clone the `semmle-code` repository inside your local `docs-internal` repository.
22+
2. [Install Pandoc](https://pandoc.org/installing.html). You can `brew install pandoc` on macOS.
23+
3. Run `src/codeql-cli/scripts/sync.js`.
24+
25+
## About this directory
26+
27+
- `src/rest/lib/config.json` - A configuration file used to specify metadata about the REST pipeline.
28+
- `src/rest/scripts` - The scripts and source code used run the CodeQL CLI pipeline.
29+
- `src/rest/scripts/sync.js` - The entrypoint script that runs the CodeQL CLI pipeline.
30+
31+
## Content team
32+
33+
The content writers can manually update parts of the autogenerated Markdown files in `content/code-security/codeql-cli/codeql-cli-manual`. When new Markdown files are added they will get all of the frontmatter properties defined in the `defaultFrontmatter` property in `src/codeql-cli/lib/config.js`.
34+
35+
When a new Markdown file is created, a writer can manually change any of the frontmatter. The pipeline will not overwrite the frontmatter on subsequent runs.
36+
37+
Writers can also add an introduction paragraph _above_ the following Markdown comment:
38+
39+
```markdown
40+
<!-- Content after this section is automatically generated -->
41+
```
42+
1143
## How to get help
44+
45+
Slack: `#docs-engineering`
46+
Repo: `github/docs-engineering`
47+
48+
If you have a question about the CodeQL CLI pipeline, you can ask in the `#docs-engineering` Slack channel. If you notice a problem with the CodeQL CLI pipeline, you can open an issue in the `github/docs-engineering` repository.
211 KB
Loading

src/github-apps/README.md

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,56 @@
1-
# GitHub Apps
1+
# GitHub Apps pipeline
22

3-
Our GitHub Apps pipeline adds automated documentation for GitHub Apps.
3+
Our GitHub Apps pipeline creates autogenerated documentation for docs.github.com from the OpenAPI stored in the open-source repository [`github/rest-api-description`](https://github.com/github/rest-api-description).
44

5-
## What is GitHub Apps
6-
7-
GitHub Apps is a GitHub product that allows custom applications to respond to events on GitHub.
5+
The pipeline is used to generate data that is used by the docs.github.com site when deployed locally, in preview environments, or in production.
86

97
## How does it work
108

9+
![A flow chart describing how the automation pipeline for GitHub Apps generates documentation](./github-apps-pipeline-flowchart.png)
10+
11+
A [workflow](.github/workflows/sync-openapi.yml) is used to trigger the automation of the GitHub Apps documentation. The workflow runs automatically on a schedule. The workflow that triggers the GitHub Apps pipeline also triggers other automation pipelines that use the OpenAPI as the source data:
12+
- GitHub Apps
13+
- REST
14+
- Webhooks
15+
16+
The workflow automatically creates a pull request with the changes (for all three pipelines) and the label `github-openapi-bot`.
17+
18+
The workflow runs the `src/rest/scripts/update-files.js` script.
19+
20+
## Local development
21+
22+
To run the GitHub Apps pipeline locally:
23+
24+
1. Clone the [`github/rest-api-description`](https://github.com/github/rest-api-description) repository inside your local `docs-internal` repository.
25+
1. Run `src/rest/scripts/update-files.js -s rest-api-description -o github-apps`.
26+
27+
## About this directory
28+
29+
- `src/rest/data` - The automatically generated data files created by running this pipeline.
30+
- `src/rest/lib` - The source code used in production for the automated documentation generated by the GitHub Apps pipeline and configuration files edited by content and engineering team members.
31+
- `src/rest/lib/config.json` - A configuration file used to specify metadata about the GitHub Apps pipeline. This file contains the SHA of the commit in `github/rest-api-description` that was used to generate the data in `src/github-apps/data`. This value is automatically updated when the pipeline runs.
32+
- `src/rest/scripts` - The scripts and source code used run the GitHub Apps pipeline, which updates the `src/github-apps/data` directory.
33+
- `src/rest/tests` - The tests used to verify the GitHub Apps pipeline.
34+
35+
## Configuring the pipeline
36+
37+
The `src/github-apps/lib/config.json` file can contain any metadata needed by the content and engineering teams to configure the webhooks pipeline. The file currently only contains the following property:
38+
39+
- `sha` - The SHA of the commit in `github/rest-api-description` that was used to generate the data in `src/github-apps/data`. This value is automatically updated when the pipeline runs.
40+
41+
## Content team
42+
43+
The content writers can manually update parts of the autogenerated Markdown file `content/rest/overview/endpoints-available-for-github-apps.md`. All frontmatter properties except `versions` can be manually modified and will not be overwritten on subsequent runs of the pipeline. The pipeline does update the `versions` property on each run.
44+
45+
Writers can also add an introduction paragraph _above_ the following Markdown comment:
46+
47+
```markdown
48+
<!-- Content after this section is automatically generated -->
49+
```
50+
1151
## How to get help
52+
53+
Slack: `#docs-engineering`
54+
Repo: `github/docs-engineering`
55+
56+
If you have a question about the GitHub Apps pipeline, you can ask in the `#docs-engineering` Slack channel. If you notice a problem with the GitHub Apps pipeline, you can open an issue in the `github/docs-engineering` repository.
219 KB
Loading

src/rest/README.md

Lines changed: 59 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,71 @@
1-
# REST
1+
# REST pipeline
2+
3+
Our REST pipeline creates autogenerated REST API documentation for docs.github.com/rest from the OpenAPI stored in the open-source repository [`github/rest-api-description`](https://github.com/github/rest-api-description).
4+
5+
The pipeline is used to generate data that is used by the docs.github.com site when deployed locally, in preview environments, or in production.
6+
7+
## How does it work
8+
9+
![A flow chart describing how the automation pipeline for REST generates documentation](./rest-pipeline-flowchart.png)
10+
11+
A [workflow](.github/workflows/sync-openapi.yml) is used to trigger the automation of the REST documentation. The workflow runs automatically on a schedule. The workflow that triggers the REST pipeline also triggers other automation pipelines that use the OpenAPI as the source data:
12+
- GitHub Apps
13+
- REST
14+
- Webhooks
15+
16+
The workflow automatically creates a pull request with the changes (for all three pipelines) and the label `github-openapi-bot`. The workflow runs the `src/rest/scripts/update-files.js` script, which creates, deletes, or updates Markdown files in the `content/rest` directory.
17+
18+
### Triggering the workflow sooner than the scheduled time
19+
20+
You can manually run the workflow leaving the source branch input parameter with the default value of `main`. Running the workflow creates a new pull request in the `github/docs-internal` repo with the changes.
21+
22+
### Triggering the workflow with a different source branch
23+
24+
If there is a pull request that is still unmerged in `github/rest-api-description` that needs to be propagated to the docs.github.com site, manually run the workflow and provide the branch name of the pull request in the `github/rest-api-description` repo that you would like to get the changes from. This will create a new pull request in the `github/docs-internal` repo with the changes.
25+
26+
## Local development
27+
28+
To run the REST pipeline locally:
29+
30+
1. Clone the [`github/rest-api-description`](https://github.com/github/rest-api-description) repository inside your local `docs-internal` repository.
31+
1. Run `src/rest/scripts/update-files.js -s rest-api-description -o rest`. Note, by default `-o rest` is specified, so you can omit it.
232

333
## About this directory
434

5-
* `src/rest/lib/index.js` is human-editable.
6-
* `src/rest/data/*.json` are generated by [scripts](../../src/rest/scripts/README.md).
35+
- `src/rest/api` - The source code for the api endpoint used in production that redirects specific anchor links on a page under `docs.github.com/rest`.
36+
- `src/rest/data` - The automatically generated data files created by running this pipeline.
37+
- `src/rest/lib` - The source code used in production for the automated documentation generated by the REST pipeline and configuration files edited by content and engineering team members.
38+
- `src/rest/lib/config.json` - A configuration file used to specify metadata about the REST pipeline.
39+
- `src/rest/scripts` - The scripts and source code used run the REST pipeline, which updates the `src/rest/data` directory.
40+
- `src/rest/scripts/update-files.js` - The entrypoint script that runs the REST pipeline.
41+
- `src/rest/tests` - The tests used to verify the REST pipeline.
42+
43+
## Configuring the pipeline
44+
45+
The `src/rest/lib/config.json` file contain metadata used by the content and engineering team to configure the REST pipeline. The file contains the following properties:
746

8-
## Editable files
47+
- `api-versions` - A list of the calendar-date API versions that are available for each version.
48+
- `versionMapping` - A mapping of the API version name used in the OpenAPI schema in `github/rest-api-description` to the version short name used in the `github/docs-internal` repo.
49+
- `frontmatterDefaults` - A list of default frontmatter values to append to each Markdown file in `content/rest`.
50+
- `targetDirectory` - The directory in `content` where the Markdown files that correspond to this pipeline are located.
51+
- `indexOrder` - The order of the children in the `index.md` file in the `targetDirectory`. The `startsWith` keyword lists the directories under `targetDirectory` that should be listed first. All other automatically created directories are appended to this list.
52+
- `sha` - The SHA of the commit in `github/rest-api-description` that was used to generate the data in `src/rest/data` and Markdown files in `content/rest`. This value is automatically updated when the pipeline runs.
953

10-
* `src/rest/lib/index.js` consumes the static decorated schema files and exports `categories`, `operations`, and `operationsEnabledForGitHubApps` used by the REST middleware contextualizer.
54+
## Content team
1155

12-
## Static files
56+
The content writers can manually update parts of the autogenerated Markdown files in `content/rest`. When new Markdown files are added they will get all of the frontmatter properties defined in the `defaultFrontmatter` property in `src/rest/lib/config.js`.
1357

14-
Generated by `src/rest/scripts/update-files.js`:
58+
When a new Markdown file is created, a writer can manually change any of the frontmatter except `versions`. The pipeline will overwrite the `versions` property on subsequent runs, but will not modify any other frontmatter properties.
1559

16-
* `src/rest/data` - files generated from the dereferenced OpenAPI schema with the Markdown descriptions rendered in HTML
17-
* `src/rest/data/dereferenced` - **NOTE** These are only generated if you pass the --keep-dereferenced-files option and are not checked into the repository. This option is for debug only.
60+
Writers can also add an introduction paragraph _above_ the following Markdown comment:
1861

19-
## Rendering docs
62+
```markdown
63+
<!-- Content after this section is automatically generated -->
64+
```
2065

21-
When the server starts, `middleware/contextualizers/rest.js` accesses the data exported from the static decorated JSON files, fetches the data for the current version and requested path, and adds it to the `context` object. The added property is:
66+
## How to get help
2267

23-
* `req.context.currentRestOperations` - all operations with a category matching the current path
68+
Slack: `#docs-engineering`
69+
Repo: `github/docs-engineering`
2470

25-
Markdown files in `content/rest/reference` use Liquid to loop over these context properties. The Liquid calls HTML files in the `includes` directory to do most of the rendering. Writers can add content to the Markdown files alongside the Liquid.
71+
If you have a question about the REST pipeline, you can ask in the `#docs-engineering` Slack channel. If you notice a problem with the REST pipeline, you can open an issue in the `github/docs-engineering` repository.
318 KB
Loading

0 commit comments

Comments
 (0)