mirror of
https://github.com/alibaba/higress.git
synced 2026-02-23 20:20:50 +08:00
126 lines
3.8 KiB
YAML
126 lines
3.8 KiB
YAML
name: "Helm Docs"
|
|
|
|
on:
|
|
pull_request:
|
|
branches:
|
|
- "*"
|
|
paths:
|
|
- 'helm/**'
|
|
workflow_dispatch: ~
|
|
push:
|
|
branches: [ main ]
|
|
paths:
|
|
- 'helm/**'
|
|
|
|
jobs:
|
|
helm:
|
|
name: Helm Docs
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Setup Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.22.9'
|
|
|
|
- name: Run helm-docs
|
|
run: |
|
|
GOBIN=$PWD GO111MODULE=on go install github.com/norwoodj/helm-docs/cmd/helm-docs@v1.14.2
|
|
./helm-docs -c ${GITHUB_WORKSPACE}/helm/higress -f ../core/values.yaml
|
|
DIFF=$(git diff ${GITHUB_WORKSPACE}/helm/higress/*md)
|
|
if [ ! -z "$DIFF" ]; then
|
|
echo "Please use helm-docs in your clone, of your fork, of the project, and commit a updated README.md for the chart."
|
|
fi
|
|
git diff --exit-code
|
|
rm -f ./helm-docs
|
|
|
|
translate-readme:
|
|
needs: helm
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y jq
|
|
|
|
- name: Compare README.md
|
|
id: compare_readme
|
|
run: |
|
|
cd ./helm/higress
|
|
BASE_BRANCH=main
|
|
UPSTREAM_REPO=https://github.com/alibaba/higress.git
|
|
|
|
TEMP_DIR=$(mktemp -d)
|
|
git clone --depth 1 --branch $BASE_BRANCH $UPSTREAM_REPO $TEMP_DIR
|
|
|
|
if diff -q "$TEMP_DIR/README.md" README.md > /dev/null; then
|
|
echo "README.md has no changes in comparison to base branch. Skipping translation."
|
|
echo "skip_translation=true" >> $GITHUB_ENV
|
|
else
|
|
echo "README.md has changed in comparison to base branch. Proceeding with translation."
|
|
echo "skip_translation=false" >> $GITHUB_ENV
|
|
fi
|
|
|
|
- name: Translate README.md to Chinese
|
|
if: env.skip_translation == 'false'
|
|
env:
|
|
API_URL: ${{ secrets.HIGRESS_OPENAI_API_URL }}
|
|
API_KEY: ${{ secrets.HIGRESS_OPENAI_API_KEY }}
|
|
API_MODEL: ${{ secrets.HIGRESS_OPENAI_API_MODEL }}
|
|
run: |
|
|
cd ./helm/higress
|
|
FILE_CONTENT=$(cat README.md)
|
|
|
|
PAYLOAD=$(jq -n \
|
|
--arg model "$API_MODEL" \
|
|
--arg content "$FILE_CONTENT" \
|
|
'{
|
|
model: $model,
|
|
messages: [
|
|
{"role": "system", "content": "You are a translation assistant that translates English Markdown text to Chinese."},
|
|
{"role": "user", "content": $content}
|
|
],
|
|
temperature: 1.1,
|
|
stream: false
|
|
}')
|
|
|
|
RESPONSE=$(curl -s -X POST "$API_URL" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Authorization: Bearer $API_KEY" \
|
|
-d "$PAYLOAD")
|
|
|
|
echo "Response: $RESPONSE"
|
|
|
|
echo "$RESPONSE" | jq -c -r '.choices[] | .message.content' > README.zh.new.md
|
|
|
|
if [ -f "README.zh.new.md" ]; then
|
|
echo "Translation completed and saved to README.zh.new.md."
|
|
else
|
|
echo "Translation failed or no content returned!"
|
|
exit 1
|
|
fi
|
|
|
|
mv README.zh.new.md README.zh.md
|
|
|
|
- name: Create Pull Request
|
|
if: env.skip_translation == 'false'
|
|
uses: peter-evans/create-pull-request@v7
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
commit-message: "Update helm translated README.zh.md"
|
|
branch: update-helm-readme-zh
|
|
title: "Update helm translated README.zh.md"
|
|
body: |
|
|
This PR updates the translated README.zh.md file.
|
|
|
|
- Automatically generated by GitHub Actions
|
|
labels: translation, automated
|
|
base: main |