Skip to content

Commit 16a70e4

Browse files
authored
ci: simplify translate workflow by using gh instead of peter-evans/create-pull-request (#2237)
1 parent 1f48432 commit 16a70e4

2 files changed

Lines changed: 24 additions & 17 deletions

File tree

.github/workflows/lint.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3131
LINTER_RULES_PATH: /
3232
MARKDOWN_CONFIG_FILE: .markdown-lint.yaml
33+
FILTER_REGEX_EXCLUDE: docs/(cn|es|fr|ja|pt-br|ru|tr)/
3334
VALIDATE_CPP: false
3435
VALIDATE_JSCPD: false
3536
VALIDATE_GO: false

.github/workflows/translate.yaml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ jobs:
2020
uses: actions/checkout@v6
2121
with:
2222
fetch-depth: 0
23-
persist-credentials: false
23+
# zizmor: ignore[artipacked]
24+
# persist-credentials is intentionally left enabled (unlike other workflows)
25+
# because this workflow needs to push a branch via git push
2426
- id: md_files
2527
run: |
2628
FILES=$(git diff --name-only "${{ github.event.before }}" "${{ github.sha }}" -- 'docs/*.md')
@@ -47,23 +49,27 @@ jobs:
4749
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4850
LINTER_RULES_PATH: /
4951
MARKDOWN_CONFIG_FILE: .markdown-lint.yaml
50-
FIX_NATURAL_LANGUAGE: true
52+
VALIDATE_NATURAL_LANGUAGE: false
5153
FIX_MARKDOWN: true
5254
- name: Create Pull Request
5355
if: steps.md_files.outputs.found == 'true'
54-
uses: peter-evans/create-pull-request@v8
5556
env:
56-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57-
with:
58-
title: "docs: update translations"
59-
commit-message: "docs: update translations"
60-
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
61-
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com>
62-
branch: translations/${{ github.run_id }}
63-
delete-branch: true
64-
body: |
65-
Translation updates for: ${{ steps.md_files.outputs.files }}.
66-
labels: |
67-
translations
68-
bot
69-
draft: false
57+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
ACTOR: ${{ github.actor }}
59+
ACTOR_ID: ${{ github.actor_id }}
60+
RUN_ID: ${{ github.run_id }}
61+
MD_FILES_LIST: ${{ steps.md_files.outputs.files }}
62+
run: |
63+
git config user.name "github-actions[bot]"
64+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
65+
BRANCH="translations/$RUN_ID"
66+
git checkout -b "$BRANCH"
67+
git add docs/
68+
git diff --cached --quiet && exit 0
69+
git commit -m "docs: update translations" --author="$ACTOR <$ACTOR_ID+$ACTOR@users.noreply.github.com>"
70+
git push origin "$BRANCH"
71+
gh pr create \
72+
--title "docs: update translations" \
73+
--body "Translation updates for: $MD_FILES_LIST." \
74+
--label "translations" \
75+
--label "bot"

0 commit comments

Comments
 (0)