Skip to content

Generate CRD docs

Generate CRD docs #205

name: Generate CRD docs
on:
workflow_dispatch:
# no content, allows manual triggering
schedule:
# 5:35 pm every Sunday (UTC)
# to ensure the docs are never too stale
- cron: "35 17 * * 0"
jobs:
gen-crd-docs:
runs-on: ubuntu-latest
permissions:
contents: read
packages: read
# Only run this scheduled job on the main repo, it can't work elsewhere
if: ${{ github.repository == 'Azure/azure-service-operator' }}
steps:
- name: Create token
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # pinned to v3.1.1
id: app-token
with:
# required
app-id: ${{ secrets.AUTOMATION_ID }}
private-key: ${{ secrets.AUTOMATION_KEY }}
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned to 6.0.2
with:
ref: main
- name: Create Branch
uses: peterjgrainger/action-create-branch@4b81ce657e255acd677cc6c55c9c763654be3aef # pinned to v4.0.0
env:
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
with:
branch: ${{ format('bot/update-api-docs-{0}', github.run_number) }}
- name: Checkout code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # pinned to 6.0.2
with:
ref: ${{ format('bot/update-api-docs-{0}', github.run_number) }}
fetch-depth: 0 # required to access tags
submodules: "true"
- name: Log in to GitHub Docker Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # pinned to v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build devcontainer image
run: |
docker build --cache-from ghcr.io/azure/azure-service-operator/aso-devcontainer:latest --tag devcontainer:latest -f .devcontainer/Dockerfile .
env:
DOCKER_BUILDKIT: 1
- name: Run devcontainer image
id: devcontainer
run: |
container_id=$(docker create -w /workspace -v $GITHUB_WORKSPACE:/workspace -v /var/run/docker.sock:/var/run/docker.sock devcontainer:latest)
docker start "$container_id"
echo "container_id=$container_id" >> $GITHUB_ENV
- name: Generate API docs
run: |
container_id=${{ env.container_id }}
docker exec "$container_id" task controller:gen-crd-docs
# After generating the API docs (above), regenerate our index files as now new CRDs can be linked to their docs
# Have to force this to ensure the index files are updated
- name: Generate Index files
run: |
container_id=${{ env.container_id }}
docker exec "$container_id" task controller:generate-types
# Workaround for getting "Permission denied" errors when trying to stage files
- name: Take Ownership
run: sudo chown -R $USER:$USER .
- name: Create Pull Request
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # pinned to v8.1.1
with:
token: ${{ steps.app-token.outputs.token }}
commit-message: Update API Docs
branch: ${{ format('bot/update-api-docs-{0}', github.run_number) }}
base: main
delete-branch: true
add-paths: ./docs/hugo/content/
title: "[Automated] Add API Docs"
body: |
Update API documentation for ASO Custom Resource Definitions
Auto-generated by [create-pull-request][1]
[1]: https://github.com/peter-evans/create-pull-request
labels: |
automated pr