Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Commit dad30c6

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

File tree

5 files changed

+130
-70
lines changed

5 files changed

+130
-70
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,48 @@ 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:
17-
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
26-
27-
- name: Set up Docker Buildx
28-
id: buildx
29-
uses: crazy-max/ghaction-docker-buildx@v1
30-
with:
31-
version: latest
32-
33-
- name: Available platforms
34-
run: echo ${{ steps.buildx.outputs.platforms }}
35-
36-
- name: Prepare Host
37-
run: |
38-
sudo apt-get -qq update || true
39-
sudo apt-get install -y bzr
40-
41-
- name: Run checks
42-
run: |
43-
make ci
44-
45-
- name: Build
46-
env:
47-
REGISTRY: appscodeci
48-
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
49-
USERNAME: 1gtm
50-
run: |
51-
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
52-
make push
16+
- name: Set up Go 1.14
17+
uses: actions/setup-go@v1
18+
with:
19+
go-version: 1.14
20+
id: go
21+
22+
- name: Check out code into the Go module directory
23+
uses: actions/checkout@v1
24+
25+
- name: Set up Docker Buildx
26+
id: buildx
27+
uses: crazy-max/ghaction-docker-buildx@v1
28+
with:
29+
version: latest
30+
31+
- name: Available platforms
32+
run: echo ${{ steps.buildx.outputs.platforms }}
33+
34+
- name: Prepare Host
35+
run: |
36+
sudo apt-get -qq update || true
37+
sudo apt-get install -y bzr
38+
39+
- name: Run checks
40+
run: |
41+
make ci
42+
43+
- name: Build
44+
env:
45+
REGISTRY: appscodeci
46+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
47+
USERNAME: 1gtm
48+
run: |
49+
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
50+
make push

.github/workflows/release.yml

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,35 @@ 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-
version: latest
28-
29-
- name: Available platforms
30-
run: echo ${{ steps.buildx.outputs.platforms }}
31-
32-
- name: Build
33-
env:
34-
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
35-
USERNAME: 1gtm
36-
APPSCODE_ENV: prod
37-
run: |
38-
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
39-
make release
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+
version: latest
26+
27+
- name: Available platforms
28+
run: echo ${{ steps.buildx.outputs.platforms }}
29+
30+
- name: Build
31+
env:
32+
DOCKER_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
33+
USERNAME: 1gtm
34+
APPSCODE_ENV: prod
35+
run: |
36+
docker login --username ${USERNAME} --password ${DOCKER_TOKEN}
37+
make release

.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: Update docs
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
@@ -66,10 +66,17 @@ aliases:
6666
`))
6767
)
6868

69+
func docsDir() string {
70+
if dir, ok := os.LookupEnv("DOCS_ROOT"); ok {
71+
return dir
72+
}
73+
return runtime.GOPath() + "/src/kubevault.dev/docs"
74+
}
75+
6976
// ref: https://github.com/spf13/cobra/blob/master/doc/md_docs.md
7077
func main() {
7178
rootCmd := cmds.NewRootCmd()
72-
dir := runtime.GOPath() + "/src/kubevault.dev/docs/docs/reference/csi-driver"
79+
dir := filepath.Join(docsDir(), "docs", "reference", "csi-driver")
7380
fmt.Printf("Generating cli markdown tree in: %v\n", dir)
7481
err := os.RemoveAll(dir)
7582
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/csi-driver/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)