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: if: ${{ ! always() }} 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: Translate README.md to Chinese 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" TRANSLATED_CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content') if [ -z "$TRANSLATED_CONTENT" ]; then echo "Translation failed! Response: $RESPONSE" exit 1 fi echo "$TRANSLATED_CONTENT" > README.zh.new.md echo "Translation completed and saved to README.zh.new.md." - name: Compare README.zh.md id: compare run: | cd ./helm/higress NEW_README_ZH="README.zh.new.md" EXISTING_README_ZH="README.zh.md" if [ ! -f "$EXISTING_README_ZH" ]; then echo "Add README.zh.md." mv "$NEW_README_ZH" "$EXISTING_README_ZH" echo "updated=true" >> $GITHUB_ENV exit 0 fi if ! diff -q "$NEW_README_ZH" "$EXISTING_README_ZH"; then echo "Files are different. Updating README.zh.md." mv "$NEW_README_ZH" "$EXISTING_README_ZH" echo "updated=true" >> $GITHUB_ENV else echo "Files are identical. No update needed." echo "updated=false" >> $GITHUB_ENV fi