-
Notifications
You must be signed in to change notification settings - Fork 333
81 lines (80 loc) · 2.78 KB
/
update-docs.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
name: "Update docs"
on:
push:
paths:
- CHANGELOG.md
- versions.yml
- UPGRADE.md
- docs/generated/raw/**
branches-ignore:
- release-*
workflow_dispatch: {}
schedule:
- cron: 0 8 * * *
env:
DOCS_REPO: kumahq/kuma-website
OUTPUT_PATH: app/docs
VERSION_FILE: app/_data/versions.yml
EDITION: kuma
jobs:
generate-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
path: repo
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
- name: "sync docs" # loop over all the branches and generate the docs
run: |
cd repo
for b in $(jq -r '.[]' active-branches.json); do
name=$(echo "${b}" | sed 's/release-\(.*\)/\1.x/g' | sed 's/master/dev/g')
echo "${b} ${name}"
git checkout --force "${b}"
mkdir -p ../docs-build/${name}
cp -R docs/generated/raw/* ../docs-build/${name}/
mkdir -p ../docs-build/raw
if [[ "${b}" == "master" ]]; then
if [[ -f UPGRADE.md ]]; then
cp UPGRADE.md ../docs-build/raw/
fi
cp CHANGELOG.md ../docs-build/raw/
cp versions.yml ../docs-build/raw/
fi
done
- uses: actions/checkout@v3
with:
repository: ${{ env.DOCS_REPO }}
path: docs
- name: "update versions"
run: |
cd docs
cp -R ../docs-build/* ${{ env.OUTPUT_PATH }}/
yq -i 'del(.[] | select(.edition == "${{ env.EDITION }}")) | . += load("${{ env.OUTPUT_PATH}}/raw/versions.yml")' ${{ env.VERSION_FILE }}
rm ${{ env.OUTPUT_PATH }}/raw/versions.yml
- name: Generate GitHub app token
id: github-app-token
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: "Create Pull Request"
uses: peter-evans/create-pull-request@v5
with:
path: docs
commit-message: "chore(deps): update docs from repo source"
signoff: true
branch: chore/docs-sync-${{github.repository}}
body: |
Syncing docs from source code.
Generated by [action](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
delete-branch: true
title: "chore(deps): update docs from repo source"
draft: false
token: ${{ steps.github-app-token.outputs.token }}
committer: kumahq[bot] <110050114+kumahq[bot]@users.noreply.github.com>
author: kumahq[bot] <110050114+kumahq[bot]@users.noreply.github.com>