3.6. Generating TechDocs Pipelines with GitHub Actions
Red Hat Developer Hub (RHDH) includes a built-in TechDocs builder, however, the default setup is not intended for production use. Deploying TechDocs documentation in a production environment involves the following actions:
- Building the documentation in a CI/CD system
- Publishing the generated documentation site to external object storage, such as AWS S3, to ensure that the generated documentation persists between restarts of RHDH and can handle larger documentation workloads.
- Configuring TechDocs in your RHDH deployment to run in read-only mode so that TechDocs reads the static generated documentation files from the cloud storage bucket without attempting to generate them at runtime.
You can implement a TechDocs pipeline using GitHub Actions to automatically generate and publish your TechDocs whenever a user in your organization makes a change to a documentation file stored in your GitHub repository.
Prerequisites
- The TechDocs plugin is enabled and configured on your RHDH instance.
- Your organization has documentation files stored in a remote repository.
- You have an mkdocs.yaml file located in the root directory of your repository.
-
You have the
catalog.entity.createandcatalog.location.createpermissions to import documentation into TechDocs from a remote repository. - You have an AWS S3 bucket to store your TechDocs sites.
- Minimal IAM Policies are configured for your S3 bucket, granting both Write and Read access.
- An administrator has created an IAM User, attached the necessary policy, and generated an access key in the AWS console.
Procedure
Set up the GitHub Actions workflow.
On GitHub, create a fork of the RHDH TechDocs Pipeline repository.
참고The
rhdh-techdocs-pipelinerepository contains agenerate-and-publish-techdocs.yamlworkflow that automatically generates TechDocs from the docs folder and publishes them to an Amazon S3 bucket.- Use the GitHub GUI to make sure that all of the permissions required to run the workflow are enabled.
Add the Repository secrets required to connect the workflow to your AWS account, for example,
TECHDOCS_S3_BUCKET_NAME,AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_REGION.참고The default
mkdocs.yamlfile in therhdh-techdocs-pipelineworkflow installs thetechdocs-coreandminifyplugins.-
Optional: Customize the default structure or files of the
rhdh-techdocs-pipelinerepository to meet the needs of your organization. -
Optional: Add other
mkdocsplugins that you want to use by adding the name of the plugins to thepluginssection of themkdocs.yamlfile and to thesteps.name: install mkdocs and mkdocs pluginssection of thegenerate-and-publish-techdocs.yamlfile.
-
. In the navigation menu of the OpenShift Container Platform console, click ConfigMaps and select your RHDH
app-config.yamlfile. Update the
app-config.yamlfile to enable your Amazon S3 bucket to serve TechDocs to your RHDH instance. For example:techdocs: builder: external publisher: type: awsS3 awsS3: bucketName: ${AWS_S3_BUCKET_NAME} accountId: ${AWS_ACCOUNT_ID} region: ${AWS_REGION} aws: accounts: - accountId: ${AWS_ACCOUNT_ID} accessKeyId: ${AWS_ACCESS_KEY_ID} secretAccessKey: ${AWS_SECRET_ACCESS_KEY} catalog: locations: - type: url target: https://github.com/<your_org>/rhdh-techdocs-pipeline/blob/main/catalog-info.yaml- Click Save.
In the navigation menu of the OpenShift Container Platform console, click Topology and restart the pod.
참고Changes to the
docsfolder or themkdocs.yamlfile trigger therhdh-techdocs-pipelineworkflow to run. After therhdh-techdocs-pipelineworkflow runs successfully, the generated TechDocs are uploaded to your Amazon S3 bucket.
Verification
- Go to your RHDH instance and click Docs to see the TechDocs served from your Amazon S3 bucket.