diff --git a/.github/workflows/latest-version.yml b/.github/workflows/latest-version.yml new file mode 100644 index 00000000..6fd2a875 --- /dev/null +++ b/.github/workflows/latest-version.yml @@ -0,0 +1,31 @@ +name: 🤖Using latest version to fix docs +on: + push: + branches: + - main +jobs: + latest-docs: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + - name: Use command to generate version + run: | + bash scripts/latest_version.sh + - uses: peter-evans/create-pull-request@v5 + if: "steps.tagpr.outputs.version != ''" + with: + title: 'Release sealos docs for latest version' + body: | + + Automated changes by [create-pull-request](https://github.com/peter-evans/create-pull-request) GitHub action + commit-message: | + 🤖 New release for sealos docs using robot. + branch: docs-robot-latest + draft: true + signoff: true + delete-branch: true + token: ${{ secrets.GITHUB_TOKEN }} + committer: github-actions[bot] + author: github-actions[bot] \ No newline at end of file diff --git a/scripts/latest_version.sh b/scripts/latest_version.sh new file mode 100755 index 00000000..e8d22db5 --- /dev/null +++ b/scripts/latest_version.sh @@ -0,0 +1,27 @@ +#!/bin/bash +# Copyright © 2022 sealos. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +fetchURL="https://raw.githubusercontent.com/labring/sealos/refs/heads/main/.tagpr.json" + +PRE_VERSION=$(curl -s ${fetchURL} | jq -r '".pre-version"') +TAG=$(curl -s ${fetchURL} | jq -r '.version') + +## check version is release version +if [[ ${TAG} =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "!!!!! is release version, will update docs" + sed -i "s#${PRE_VERSION}#${TAG}#g" content/docs/self-hosting/install.zh-cn.mdx +else + echo "!!!!! is not release version, will skip update docs" +fi \ No newline at end of file