From 0869aa161a151b68f7f5ab7eda34e7285ff87a04 Mon Sep 17 00:00:00 2001 From: Himanshu Mishra Date: Wed, 10 Feb 2021 19:31:00 +0100 Subject: [PATCH 1/2] docs(TechDocs): Add GitHub Actions CI example with AWS S3 --- docs/features/techdocs/configuring-ci-cd.md | 81 +++++++++++++++++++-- 1 file changed, 75 insertions(+), 6 deletions(-) diff --git a/docs/features/techdocs/configuring-ci-cd.md b/docs/features/techdocs/configuring-ci-cd.md index 5841a02fa8..660c7ce97f 100644 --- a/docs/features/techdocs/configuring-ci-cd.md +++ b/docs/features/techdocs/configuring-ci-cd.md @@ -27,11 +27,15 @@ REPOSITORY_URL='https://github.com/org/repo' git clone $REPOSITORY_URL cd repo +# Install @techdocs/cli, mkdocs and mkdocs plugins +npm install -g @techdocs/cli +pip install mkdocs-techdocs-core==0.* + # Generate -npx @techdocs/cli generate +techdocs-cli generate --no-docker # Publish -npx @techdocs/cli publish --publisher-type awsS3 --storage-name --entity +techdocs-cli publish --publisher-type awsS3 --storage-name --entity ``` That's it! @@ -40,14 +44,16 @@ Take a look at [`techdocs-cli` README](https://github.com/backstage/techdocs-cli) for the complete command reference, details, and options. -## 1. Setup a workflow +## Steps + +### 1. Setup a workflow The TechDocs workflow should trigger on CI when any changes are made in the repository containing the documentation files. You can be specific and configure the workflow to be triggered only when files inside the `docs/` directory or `mkdocs.yml` are changed. -## 2. Prepare step +### 2. Prepare step The first step on the CI is to clone your documentation source repository in a working directory. This is almost always the first step in most CI workflows. @@ -62,7 +68,7 @@ step. Eventually we are trying to do a `git clone `. -## 3. Generate step +### 3. Generate step Install [`npx`](https://www.npmjs.com/package/npx) to use it for running `techdocs-cli`. Or you can install using `npm install -g @techdocs/cli`. @@ -78,7 +84,7 @@ npx @techdocs/cli generate --no-docker --source-dir PATH_TO_REPO --output-dir ./ `PATH_TO_REPO` should be the location in the file path where the prepare step above clones the repository. -## 4. Publish step +### 4. Publish step Depending on your cloud storage provider (AWS, Google Cloud, or Azure), set the necessary authentication environment variables. @@ -96,3 +102,66 @@ npx @techdocs/cli publish --publisher-type --storage-name Date: Thu, 11 Feb 2021 09:28:08 +0100 Subject: [PATCH 2/2] docs(TechDocs): Improvements to the CI example Signed-off-by: Himanshu Mishra --- docs/features/techdocs/configuring-ci-cd.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/features/techdocs/configuring-ci-cd.md b/docs/features/techdocs/configuring-ci-cd.md index 660c7ce97f..a9844ef528 100644 --- a/docs/features/techdocs/configuring-ci-cd.md +++ b/docs/features/techdocs/configuring-ci-cd.md @@ -106,8 +106,8 @@ the TechDocs plugin in your Backstage app. ## Example: GitHub Actions CI and AWS S3 Here is an example workflow using GitHub Actions CI and AWS S3 storage. You can -use any CI and other cloud storage providers - Google Cloud Storage and Azure -Blob Storage. +use any CI and any other +[TechDocs supported cloud storage providers](README.md#platforms-supported). Add a `.github/workflows/techdocs.yml` file in your [Software Template(s)](../software-templates/index.md) like this - @@ -136,9 +136,10 @@ jobs: AWS_REGION: ${{ secrets.AWS_REGION }} ENTITY_NAMESPACE: 'default' ENTITY_KIND: 'Component' + ENTITY_NAME: 'my-doc-entity' # In a Software template, Scaffolder will replace {{cookiecutter.component_id | jsonify}} # with the correct entity name. This is same as metadata.name in the entity's catalog-info.yaml - ENTITY_NAME: '{{ cookiecutter.component_id | jsonify }}' + # ENTITY_NAME: '{{ cookiecutter.component_id | jsonify }}' steps: - name: Checkout code @@ -163,5 +164,6 @@ jobs: $ENTITY_NAMESPACE/$ENTITY_KIND/$ENTITY_NAME ``` -When the new Software is created, the first GitHub Action workflow will publish -the TechDocs site, which can be viewed in your Backstage app. +When the new repository is scaffolded or new documentation updates are +committed, the GitHub Action workflow will publish the TechDocs site, which can +be viewed in your Backstage app.