Skip to content

Commit 18ce00b

Browse files
authored
Add workflow to update docs (#29)
Signed-off-by: Tamal Saha <tamal@appscode.com>
1 parent 2767953 commit 18ce00b

File tree

5 files changed

+125
-65
lines changed

5 files changed

+125
-65
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,30 @@ name: CI
33
on:
44
pull_request:
55
branches:
6-
- '*'
6+
- "*"
77
push:
88
branches:
99
- master
1010

1111
jobs:
12-
1312
build:
1413
name: Build
1514
runs-on: ubuntu-latest
1615
steps:
16+
- name: Set up Go 1.14
17+
uses: actions/setup-go@v1
18+
with:
19+
go-version: 1.14
20+
id: go
1721

18-
- name: Set up Go 1.14
19-
uses: actions/setup-go@v1
20-
with:
21-
go-version: 1.14
22-
id: go
23-
24-
- name: Check out code into the Go module directory
25-
uses: actions/checkout@v1
22+
- name: Check out code into the Go module directory
23+
uses: actions/checkout@v1
2624

27-
- name: Prepare Host
28-
run: |
29-
sudo apt-get -qq update || true
30-
sudo apt-get install -y bzr
25+
- name: Prepare Host
26+
run: |
27+
sudo apt-get -qq update || true
28+
sudo apt-get install -y bzr
3129
32-
- name: Run checks
33-
run: |
34-
make ci
30+
- name: Run checks
31+
run: |
32+
make ci

.github/workflows/release.yml

Lines changed: 42 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,53 +3,51 @@ name: Release
33
on:
44
push:
55
tags:
6-
- '*.*'
6+
- "*.*"
77

88
jobs:
9-
109
build:
1110
name: Build
1211
runs-on: ubuntu-latest
1312
steps:
14-
15-
- name: Check out code into the Go module directory
16-
uses: actions/checkout@v1
17-
18-
- name: Print version info
19-
id: semver
20-
run: |
21-
make version
22-
23-
- name: Set up Docker Buildx
24-
id: buildx
25-
uses: crazy-max/ghaction-docker-buildx@v1
26-
with:
27-
buildx-version: latest
28-
qemu-version: latest
29-
30-
- name: Available platforms
31-
run: echo ${{ steps.buildx.outputs.platforms }}
32-
33-
- name: Build
34-
env:
35-
APPSCODE_ENV: prod
36-
run: |
37-
make release
38-
39-
- name: Release
40-
uses: softprops/action-gh-release@v1
41-
if: startsWith(github.ref, 'refs/tags/')
42-
with:
43-
files: |
44-
bin/kubectl-vault-linux-amd64
45-
bin/kubectl-vault-linux-arm
46-
bin/kubectl-vault-linux-arm64
47-
bin/kubectl-vault-windows-amd64.exe
48-
bin/kubectl-vault-darwin-amd64
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51-
52-
- uses: actions/upload-artifact@master
53-
with:
54-
name: kubectl-vault-binaries
55-
path: bin
13+
- name: Check out code into the Go module directory
14+
uses: actions/checkout@v1
15+
16+
- name: Print version info
17+
id: semver
18+
run: |
19+
make version
20+
21+
- name: Set up Docker Buildx
22+
id: buildx
23+
uses: crazy-max/ghaction-docker-buildx@v1
24+
with:
25+
buildx-version: latest
26+
qemu-version: latest
27+
28+
- name: Available platforms
29+
run: echo ${{ steps.buildx.outputs.platforms }}
30+
31+
- name: Build
32+
env:
33+
APPSCODE_ENV: prod
34+
run: |
35+
make release
36+
37+
- name: Release
38+
uses: softprops/action-gh-release@v1
39+
if: startsWith(github.ref, 'refs/tags/')
40+
with:
41+
files: |
42+
bin/kubectl-vault-linux-amd64
43+
bin/kubectl-vault-linux-arm
44+
bin/kubectl-vault-linux-arm64
45+
bin/kubectl-vault-windows-amd64.exe
46+
bin/kubectl-vault-darwin-amd64
47+
env:
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
50+
- uses: actions/upload-artifact@master
51+
with:
52+
name: kubectl-vault-binaries
53+
path: bin

.github/workflows/update-docs.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: update-docs
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
name: Build
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Set up Go 1.14
14+
uses: actions/setup-go@v1
15+
with:
16+
go-version: 1.14
17+
id: go
18+
19+
- uses: actions/checkout@v1
20+
21+
- name: Install GitHub CLI
22+
run: |
23+
curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
24+
sudo mv bin/hub /usr/local/bin
25+
26+
- name: Clone charts repository
27+
env:
28+
GITHUB_USER: 1gtm
29+
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
30+
DOCS_REPOSITORY: ${{ secrets.DOCS_REPOSITORY }}
31+
run: |
32+
url="https://${GITHUB_USER}:${GITHUB_TOKEN}@${DOCS_REPOSITORY}.git"
33+
cd $RUNNER_WORKSPACE
34+
git clone $url
35+
cd $(basename $DOCS_REPOSITORY)
36+
git config user.name "${GITHUB_USER}"
37+
git config user.email "${GITHUB_USER}@appscode.com"
38+
39+
- name: Package
40+
env:
41+
GITHUB_USER: 1gtm
42+
GITHUB_TOKEN: ${{ secrets.LGTM_GITHUB_TOKEN }}
43+
DOCS_REPOSITORY: ${{ secrets.DOCS_REPOSITORY }}
44+
run: |
45+
export DOCS_ROOT=$RUNNER_WORKSPACE/$(basename $DOCS_REPOSITORY)
46+
./hack/gendocs/make.sh
47+
$DOCS_ROOT/hack/scripts/open-pr.sh

hack/gendocs/main.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,17 @@ aliases:
6767
`))
6868
)
6969

70+
func docsDir() string {
71+
if dir, ok := os.LookupEnv("DOCS_ROOT"); ok {
72+
return dir
73+
}
74+
return runtime.GOPath() + "/src/kubevault.dev/docs"
75+
}
76+
7077
// ref: https://github.com/spf13/cobra/blob/master/doc/md_docs.md
7178
func main() {
7279
rootCmd := cmds.NewRootCmd()
73-
dir := runtime.GOPath() + "/src/kubevault.dev/docs/docs/reference/cli"
80+
dir := filepath.Join(docsDir(), "docs", "reference", "cli")
7481
fmt.Printf("Generating cli markdown tree in: %v\n", dir)
7582
err := os.RemoveAll(dir)
7683
if err != nil {

hack/gendocs/make.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env bash
1+
#!/bin/bash
22

33
# Copyright The KubeVault Authors.
44
#
@@ -14,6 +14,16 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
pushd $GOPATH/src/kubevault.dev/cli/hack/gendocs
17+
set -eou pipefail
18+
19+
SCRIPT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}")/../..)
20+
SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}")
21+
pushd $SCRIPT_ROOT/hack/gendocs
22+
23+
# http://redsymbol.net/articles/bash-exit-traps/
24+
function cleanup() {
25+
popd
26+
}
27+
trap cleanup EXIT
28+
1829
go run main.go
19-
popd

0 commit comments

Comments
 (0)