forked from keptn/keptn.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (85 loc) · 3.22 KB
/
auto-update.yml
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Auto Update - Docs
on:
repository_dispatch:
types: [ release-push ]
defaults:
run:
shell: bash
env:
KEPTN_BOT: "keptn-bot <[email protected]>"
jobs:
update-spec:
env:
SOURCE_REF: ${{ github.event.client_payload.ref }}
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.KEPTN_BOT_TOKEN }}
- name: Checkout
uses: actions/checkout@v3
with:
repository: keptn/keptn
path: keptn
token: ${{ secrets.KEPTN_BOT_TOKEN }}
ref: ${{ env.SOURCE_REF }}
- name: Extract source branch and commit ID
working-directory: keptn
run: |
# extract release branch version and replace minor version with x
shopt -s extglob
export "SOURCE_TAG=${SOURCE_REF#refs/tags/}"
echo "SOURCE_TAG=$SOURCE_TAG" >> $GITHUB_ENV
echo "SOURCE_VERSION_SLUG=${SOURCE_TAG/%.+([0-9])/.x}" >> $GITHUB_ENV
# extract corresponding git commit ID
SOURCE_GIT_COMMIT=$(git rev-list -n 1 "$SOURCE_TAG")
echo "SOURCE_GIT_COMMIT=$SOURCE_GIT_COMMIT" >> $GITHUB_ENV
shopt -u extglob
- name: Download CLI from release build
uses: dawidd6/[email protected]
with:
name: keptn-cli
github_token: ${{ secrets.KEPTN_BOT_TOKEN }}
workflow: CI.yml
commit: ${{ env.SOURCE_GIT_COMMIT }}
path: ./dist
repo: keptn/keptn
- name: Extract and prepare Keptn CLI
working-directory: dist
run: |
tar -xzvf ./keptn-*-linux-amd64.tar.gz
rm -f ./keptn-*.tar.gz
CLI=$(ls ./keptn-*)
mv "$CLI" ./keptn
chmod +x ./keptn
- name: Generate docs
env:
SOURCE_VERSION_SLUG: ${{ env.SOURCE_VERSION_SLUG }}
DOCS_PATH: "./content/docs/${{ env.SOURCE_VERSION_SLUG }}/reference/cli/commands"
RELATIVE_PATH: "../../../../"
run: |
if [[ ! -d "$DOCS_PATH" ]]; then
mkdir -p "$DOCS_PATH"
fi
./dist/keptn generate docs --dir="$DOCS_PATH"
# Replaces All Occurences of version links with a relative path
find $DOCS_PATH -print -type f -name '*.md' -exec sed -i "s@https://keptn.sh/docs/[[:digit:]][^/]*/@${RELATIVE_PATH}@g" {} \;
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
add-paths: "./content/docs/${{ env.SOURCE_VERSION_SLUG }}/reference/cli/commands"
token: ${{ secrets.KEPTN_BOT_TOKEN }}
commit-message: "Update keptn docs to release ${{ env.SOURCE_TAG }}"
committer: ${{ env.KEPTN_BOT }}
author: ${{ env.KEPTN_BOT }}
signoff: true
branch: patch/update-keptn-docs-${{ env.SOURCE_TAG }}-${{ github.run_number }}
delete-branch: true
base: master
labels: 'automated pr'
title: "Update keptn docs for release ${{ env.SOURCE_TAG }}"
body: |
**This is an automated PR!**
Update keptn docs to latest keptn/keptn release
New version: ${{ env.SOURCE_TAG }}