-
Notifications
You must be signed in to change notification settings - Fork 16
58 lines (54 loc) · 2.11 KB
/
publish-version.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
name: Publish new docs version
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
env:
TAG: ${{ github.ref_name }}
permissions:
contents: write
pull-requests: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: refs/tags/${{ env.TAG }}
- name: Prepare the tag
run: |
git fetch --tags
echo "TRIMMED_TAG=${TAG#v}" >> $GITHUB_ENV
echo "TAG=${TAG%.*}" >> $GITHUB_ENV
- name: Copy docs directory
run: |
mkdir -p docs/${TAG}
cp -r docs/next/* docs/${TAG}
- name: Update site.start_page with new tag
run: |
sed -i "s|start_page:.*|start_page: ${TAG}@turtles:en:index.adoc|" turtles-gh-pages-playbook.yml
- name: Prepend new tag to start_paths
run: |
sed -i "s|start_paths: \[|start_paths: [docs/${TAG}, |" turtles-gh-pages-playbook.yml
- name: Change version in antora.yml
run: |
sed -i "s/^version: .*/version: $TAG/" docs/${TAG}/antora.yml
- name: Change display_version in antora.yml
run: |
sed -i "s/^display_version: .*/display_version: '$TAG'/" docs/${TAG}/antora.yml
- name: Commit changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git checkout -b release-${{ env.TRIMMED_TAG }}
git add .
git commit -m "Add docs version v${{ env.TRIMMED_TAG }}"
git push origin release-${{ env.TRIMMED_TAG }}
tag=${{ env.TRIMMED_TAG }}
[[ $tag =~ [0-9]+\.[0-9]+\.[0-9]+ ]] || tag+=.0
echo -e "Update docs version v${tag}\\n\\nChangelog: https://github.com/rancher/turtles/releases/tag/v${tag}\\n\\ncc @rancher/highlander" > body
export body=$(cat body)
gh pr create --title 'turtles-docs release for turtles v${{ env.TRIMMED_TAG }}' --body "$body" --label "area/documentation"