corso/.github/workflows/docgen.yml

81 lines
2.5 KiB
YAML

name: Document Generation
on:
pull_request:
branches: [main]
jobs:
Generate-Markdown:
environment: Testing
runs-on: ubuntu-latest
steps:
# check out the repo
- name: Repo Code Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
# Get values for cache paths to be used in later steps
- id: go-cache-paths
working-directory: ./src
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- name: Golang Setup
uses: actions/setup-go@v3
with:
go-version: 1.18
cache: true
cache-dependency-path: src/go.sum
# download packages
- name: Cache Go Mod
uses: actions/cache@v3
id: cache
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
- name: Run go mod download
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ./src
run: go mod download
# run the markdown generator
- name: Generate Markdown
working-directory: ./src
run: |
go run ./cmd/mdgen/mdgen.go generate
# migrate generated md files into /docs/docs/cli
- name: Move CLI .md to Docs
run: |
mkdir -p ./docs/docs/cli
mv ./src/cmd/mdgen/cli_markdown/* ./docs/docs/cli/
rm -R ./src/cmd/mdgen/cli_markdown/
# make a commit for any file changes
# - name: Commit the Auto-Generated Files
# uses: stefanzweifel/git-auto-commit-action@v4
# with:
# branch: docs_autogen
# create_branch: true
# commit_message: Documentation Auto-generation
# commit_user_name: github-actions[bot]
# commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com
# commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
# make a new PR for the changes
- name: Make a New PR With the Auto-Generated Docs
uses: EndBug/add-and-commit@v9
with:
# pull: '--rebase'
new_branch: docs_autogen
push: 'origin docs_autogen --set-upstream --force'
message: 'Documentation Auto-generation'
committer_name: github-actions[bot]
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
default_author: github_actor