Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation 0.5.0 #8

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
28 changes: 28 additions & 0 deletions .github/scripts/doc-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e

DOC_TEMPLATE_SUBMODULE="docs/doc-terraform-template"

if [ "$TAG" == "" ]; then
echo "We need the tag of the doc"
exit 1
fi

# Create a branch
git checkout -b "autobuild-Documentation-$TAG"

# Update submodule
(cd $DOC_TEMPLATE_SUBMODULE && git fetch && git checkout $TAG)

# Gen the doc
make doc

# Create PR
git config user.name "Outscale Bot"
git config user.email "[email protected]"

git add $DOC_TEMPLATE_SUBMODULE
git add website/*

git commit -sm "Release Documentation $TAG"
19 changes: 19 additions & 0 deletions .github/scripts/doc-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/env bash
set -e

if [ -z "$GH_BOT_TOKEN" ]; then
echo "GH_BOT_TOKEN is missing, abort."
exit 1
fi

# https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls#create-a-pull-request
result=$(curl -s -X POST -H "Authorization: token $GH_BOT_TOKEN" -d "{\"head\":\"autobuild-Documentation-$TAG\",\"base\":\"master\",\"title\":\"Documentation $TAG\",\"body\":\"Automatic generation of the documentation $TAG\"}" "https://api.github.com/repos/outscale-mdr/terraform-provider-outscale/pulls")

errors=$(echo $result | jq .errors)

echo $errors

if [ "$errors" != "null" ]; then
echo "errors while creating pull request, abort."
exit 1
fi
17 changes: 17 additions & 0 deletions .github/scripts/doc-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e

if [ "$TAG" == "" ]; then
echo "We need the tag of the doc"
exit 1
fi

if [ "$SSH_PRIVATE_KEY" == "" ]; then
echo "We need the SSH key of the bot"
exit 1
fi

echo "$SSH_PRIVATE_KEY" > bot.key
chmod 600 bot.key
GIT_SSH_COMMAND="ssh -i bot.key" git push -f origin "autobuild-Documentation-$TAG"
31 changes: 31 additions & 0 deletions .github/workflows/generate_doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Generate documentation
on:
workflow_dispatch:
inputs:
tag:
description: 'doc template tag repository'
required: true

jobs:
doc-release:
environment: auto-build
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: 'recursive'
- uses: actions/setup-python@v2
- name: auto-generate release
run: .github/scripts/doc-build.sh
env:
TAG: ${{ github.event.inputs.tag }}
- name: push release branch
run: .github/scripts/doc-push.sh
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
TAG: ${{ github.event.inputs.tag }}
- name: create pull request
run: .github/scripts/doc-pr.sh
env:
TAG: ${{ github.event.inputs.tag }}
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ terraformStatePull.json
/tests/resources.auto.tfvars.template.cpgz
/tests/test.tf
/tests/old.py
/tests/tmp.txt
/tests/tmp.txt

# docs
docs/generation_log.txt
docs/.venv
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "docs/osc-api"]
path = docs/osc-api
url = https://github.com/outscale/osc-api
[submodule "docs/doc-terraform-template"]
path = docs/doc-terraform-template
url = https://github.com/outscale-dev/terraform-provider-outscale-doc-components.git
3 changes: 3 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,7 @@ examples-test:
cd ../..; \
done\

doc:
@sh -c "'$(CURDIR)/scripts/generate-doc.sh'"

.PHONY: build test testacc fmt fmtcheck lint tools test-compile website website-lint website-test examples-test website-local
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,14 @@ Issues and contributions
------------------------

Check [CONTRIBUTING.md](./CONTRIBUTING.md) for more details.


Building the documentation
------------------------
- Requirements:
- make
- python3
- python-venv
```shell
$ make doc
```
1 change: 1 addition & 0 deletions docs/doc-terraform-template
Submodule doc-terraform-template added at f61601
Loading