forked from keptn/lifecycle-toolkit
-
Notifications
You must be signed in to change notification settings - Fork 0
80 lines (68 loc) · 2.37 KB
/
release-docs.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
name: Release Documentation
on:
workflow_call:
inputs:
tag_name:
description: "Release Tag to use"
type: "string"
required: true
env:
PAGE_DIR: "./tmp/page"
defaults:
run:
shell: bash
jobs:
release-docs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Checkout - page branch
uses: actions/checkout@v4
with:
ref: "page"
path: ${{ env.PAGE_DIR }}
- name: Get Latest Release Information
uses: octokit/[email protected]
id: latest_release
with:
route: GET /repos/:owner/:repository/releases/latest
repository: lifecycle-toolkit
owner: keptn
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Detect current live version
id: folder
run: |
CURRENT_VERSION=`cat ${{ env.PAGE_DIR }}/docs/content/en/docs/version || echo "unknown"`
echo "Migrating to ${CURRENT_VERSION}"
echo "migrate=docs-$CURRENT_VERSION" >> $GITHUB_OUTPUT
- name: Move current live docs to a versioned folder
env:
FROM: "${{ env.PAGE_DIR }}/docs/content/en/docs"
TO: "${{ env.PAGE_DIR }}/docs/content/en/${{ steps.folder.outputs.migrate }}"
run: |
cp -R $FROM $TO
rm -rf $FROM
- name: Copy old docs into main branch status
run: |
# Copy only the docs folder into the current documentation status from main
cp -R ${{ env.PAGE_DIR }}/docs/content/en/docs-* "./docs/content/en/"
- name: Copy documentation site to page
env:
FOLDER: "${{ env.PAGE_DIR }}/docs/content/en/docs"
run: |
# clean page branch status
rm -rf ${{ env.PAGE_DIR }}/docs
cp -R ./docs ${{ env.PAGE_DIR }}/docs
# mark the new live version with the release tag
echo "${{ inputs.tag_name }}" > "${FOLDER}/version"
sed -i 's/currentversion: main/currentversion: ${{ inputs.tag_name }}/g' "${FOLDER}/_index.md"
# copy netlify conf
cp ./netlify.toml ${{ env.PAGE_DIR }}/netlify.toml
- name: Push content
uses: EndBug/add-and-commit@v9
with:
default_author: github_actions
cwd: ${{ env.PAGE_DIR }}
message: "releasing documentation ${{ inputs.tag_name }}"