mkdocs.yml update #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Extract menu strings to en.yml | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'mkdocs.yml' | |
| permissions: | |
| contents: write | |
| actions: write | |
| jobs: | |
| update-en-yml: | |
| name: Process changes in English menu items | |
| runs-on: ubuntu-latest | |
| env: | |
| MKDOCS_FILE: "mkdocs.yml" | |
| TARGET_FILE: "./docs/en/en.yml" | |
| steps: | |
| - name: ⬇️ Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: 🧰 Set up yq | |
| uses: mikefarah/yq@v4 | |
| - name: 📝 Update en.yml | |
| run: | | |
| echo "Extracting English menu items from ${MKDOCS_FILE} to ${TARGET_FILE}" | |
| TMP_FILE=$(mktemp) | |
| yq eval '(.plugins[].i18n.languages[] | select(.locale == "en")) | del(.default)' "$MKDOCS_FILE" > "$TMP_FILE" | |
| yq eval --inplace " | |
| (.en.plugins[].i18n.languages[] | select(.locale == \"en\")) = load (\"$TMP_FILE\") | |
| " "$TARGET_FILE" | |
| rm "$TMP_FILE" | |
| - name: Commit ${{ env.TARGET_FILE }} if changed | |
| run: | | |
| set -euo pipefail | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Stage first, then check what's actually pending | |
| [ -f "$TARGET_FILE" ] && git add -- "$TARGET_FILE" || true | |
| # Nothing staged? clean exit. | |
| if [ -z "$(git status --porcelain -- "$TARGET_FILE")" ]; then | |
| echo "No changes to commit for $TARGET_FILE" | |
| exit 0 | |
| fi | |
| git commit -m "Changes in $TARGET_FILE" | |
| git push origin "$BRANCH" |