-
Notifications
You must be signed in to change notification settings - Fork 446
76 lines (76 loc) · 2.75 KB
/
translate.yaml
File metadata and controls
76 lines (76 loc) · 2.75 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
name: Translate Docs
concurrency:
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref }}
on:
push:
branches:
- main
paths:
- "docs/*"
permissions:
contents: write
pull-requests: write
jobs:
build:
environment: translate
name: Translate Docs
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v6
with:
fetch-depth: 0
# zizmor: ignore[artipacked]
# persist-credentials is intentionally left enabled (unlike other workflows)
# because this workflow needs to push a branch via git push
- id: md_files
run: |
FILES=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- 'docs/*.md' ':(exclude)docs/*/*.md')
FILES=$(echo "$FILES" | xargs -n1 basename | tr '\n' ' ')
[ -z "$FILES" ] && echo "found=false" >> "$GITHUB_OUTPUT" || echo "found=true" >> "$GITHUB_OUTPUT"
echo "files=$FILES" >> "$GITHUB_OUTPUT"
- name: Set up PHP
if: steps.md_files.outputs.found == 'true'
uses: shivammathur/setup-php@v2
with:
php-version: "8.5"
- name: run translation script
if: steps.md_files.outputs.found == 'true'
env:
GEMINI_API_KEY: "${{ secrets.GEMINI_API_KEY }}"
MD_FILES: "${{ steps.md_files.outputs.files }}"
run: |
php ./docs/translate.php "$MD_FILES"
- name: Run Linter
if: steps.md_files.outputs.found == 'true'
continue-on-error: true
uses: super-linter/super-linter/slim@v8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
LINTER_RULES_PATH: /
MARKDOWN_CONFIG_FILE: .markdown-lint.yaml
VALIDATE_NATURAL_LANGUAGE: false
FIX_MARKDOWN: true
- name: Create Pull Request
if: steps.md_files.outputs.found == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACTOR: ${{ github.actor }}
ACTOR_ID: ${{ github.actor_id }}
RUN_ID: ${{ github.run_id }}
MD_FILES_LIST: ${{ steps.md_files.outputs.files }}
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
BRANCH="translations/$RUN_ID"
git checkout -b "$BRANCH"
git add docs/
git diff --cached --quiet && exit 0
git commit -m "docs: update translations" --author="$ACTOR <$ACTOR_ID+$ACTOR@users.noreply.github.com>"
git push origin "$BRANCH"
gh pr create \
--title "docs: update translations" \
--body "Translation updates for: $MD_FILES_LIST." \
--label "translations" \
--label "bot"