93 lines
2.9 KiB
YAML
93 lines
2.9 KiB
YAML
name: Document Generation
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
deployments: write
|
|
|
|
jobs:
|
|
precheck:
|
|
uses: alcionai/corso/.github/workflows/_filechange_checker.yml@main
|
|
|
|
Generate-Markdown:
|
|
needs: precheck
|
|
if: needs.precheck.outputs.fileschanged == 'true'
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Repo Code Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ github.event.pull_request.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 PR for the docs_autogen branch
|
|
- name: Make a PR For the `docs_autogen` Branch
|
|
uses: peter-evans/create-pull-request@v4
|
|
with:
|
|
commit-message: "Documentation Auto-Generation"
|
|
branch: docs_autogen
|
|
delete-branch: true
|
|
base: main
|
|
title: "Docs Auto-Generation"
|
|
|
|
# make sure it gets approved
|
|
- name: Auto approve
|
|
if: steps.cpr.outputs.pull-request-operation == 'created'
|
|
uses: juliangruber/approve-pull-request-action@v1
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
number: ${{ steps.cpr.outputs.pull-request-number }}
|
|
|
|
# for the future, if we create a PAT
|
|
# https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token
|
|
|
|
# # make the PR auto-merge
|
|
# - name: Enable Pull Request Automerge
|
|
# if: steps.cpr.outputs.pull-request-operation == 'created'
|
|
# uses: peter-evans/enable-pull-request-automerge@v2
|
|
# with:
|
|
# token: ${{ secrets.PAT }}
|
|
# pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
|
|
# merge-method: squash |