Generate Docs #31
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 'Generate Docs' | |
on: | |
workflow_dispatch: | |
env: | |
DOCS_TOKEN: ${{ secrets.DOCS_TOKEN }} | |
jobs: | |
generate-docs: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Calculate branch name | |
id: branch-name | |
run: echo "BRANCH_NAME=enh-cliupdate-octopus-$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV | |
- name: Checkout CLI | |
uses: actions/checkout@v3 | |
with: | |
path: cli | |
- name: Checkout docs | |
uses: actions/checkout@v3 | |
with: | |
repository: OctopusDeploy/docs | |
token: ${{ env.DOCS_TOKEN }} | |
path: docs | |
- name: Setup docs repo | |
working-directory: docs | |
run: | | |
git config user.email 'bob@octopus.com' | |
git config user.name octobob | |
git checkout main | |
git checkout -b $BRANCH_NAME | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: 1.21 | |
- name: Generate cli docs | |
working-directory: cli | |
run: mkdir -p ../docs/src/pages/docs/octopus-rest-api/cli && go run cmd/gen-docs/main.go --website --doc-path ../docs/src/pages/docs/octopus-rest-api/cli --relative-base-path /docs/octopus-rest-api/cli | |
- name: Commit | |
uses: EndBug/add-and-commit@v9 | |
with: | |
message: 'Update cli docs for octopus(go)' | |
author_name: Bob | |
author_email: bob@octopus.com | |
committer_name: bob | |
cwd: docs | |
add: src/pages/docs/octopus-rest-api/cli | |
push: false | |
- run: git push --repo https://octobob:$DOCS_TOKEN@github.com/OctopusDeploy/docs.git --set-upstream origin $BRANCH_NAME | |
working-directory: docs | |
- name: Create PR | |
run: | | |
curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: Bearer $DOCS_TOKEN" \ | |
https://api.github.com/repos/OctopusDeploy/docs/pulls \ | |
-d '{"title":"update go-cli docs","body":"An automated update of the command line docs for octopus CLI\nCreated by GitHub Actions [Generate Docs](https://github.com/OctopusDeploy/cli/actions/workflows/generate-docs.yml)","head":"'$BRANCH_NAME'","base":"main"}' |