Skip to content
Open

Test #1696

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions .github/workflows/build-docusaurus.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Build Docusaurus Documentation
on:
pull_request:
pull_request_target:
types: [labeled]
push:
branches: ["master", "main"]
Expand All @@ -19,6 +19,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.sha }}
fetch-depth: 0

- name: Setup Node.js
Expand Down Expand Up @@ -54,13 +55,17 @@ jobs:
retention-days: 90

- name: Remove label
if: always() && github.event_name == 'pull_request'
if: always() && github.event_name == 'pull_request_target'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'BUILD DOCUSAURUS'
})
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: 'BUILD DOCUSAURUS'
});
} catch (error) {
core.warning(`Could not remove label: ${error.message}`);
}
76 changes: 65 additions & 11 deletions .github/workflows/translate-docusaurus.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Translate Docusaurus Documentation

on:
pull_request:
pull_request_target:
types: [labeled]

permissions:
checks: write
contents: write
pull-requests: write

Expand All @@ -15,10 +14,10 @@ jobs:
timeout-minutes: 1440
runs-on: self-hosted
steps:
- name: Checkout PR branch
- name: Checkout PR code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Setup Node.js
Expand All @@ -42,25 +41,80 @@ jobs:
run: node translate.js

- name: Commit translations
id: commit
run: |
git config --local user.name "github-actions"
git config --local user.email "github-actions@github.com"
git add -A i18n/
if ! git diff --cached --quiet; then
git commit -m "Auto-translate docs"
git push origin HEAD:${{ github.head_ref }}
echo "has_changes=true" >> "$GITHUB_OUTPUT"
else
echo "No translation changes to commit"
echo "has_changes=false" >> "$GITHUB_OUTPUT"
fi

- name: Remove label
if: always()
- name: Push to PR branch (same-repo)
if: steps.commit.outputs.has_changes == 'true' && github.event.pull_request.head.repo.full_name == github.repository
run: git push origin HEAD:refs/heads/${{ github.head_ref }}

- name: Push translation branch (fork PR)
if: steps.commit.outputs.has_changes == 'true' && github.event.pull_request.head.repo.full_name != github.repository
run: git push origin HEAD:refs/heads/translations/pr-${{ github.event.pull_request.number }} --force

- name: Create or update translation PR (fork PR)
if: steps.commit.outputs.has_changes == 'true' && github.event.pull_request.head.repo.full_name != github.repository
uses: actions/github-script@v7
with:
script: |
github.rest.issues.removeLabel({
const prNumber = context.payload.pull_request.number;
const branch = `translations/pr-${prNumber}`;
const baseBranch = context.payload.pull_request.base.ref;

const { data: existingPRs } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'TRANSLATE DOCUSAURUS'
})
head: `${context.repo.owner}:${branch}`,
state: 'open'
});

if (existingPRs.length === 0) {
const { data: newPR } = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Auto-translate: PR #${prNumber}`,
body: `Automated translations for #${prNumber}.\n\nMerge this PR **after** #${prNumber} has been merged.`,
head: branch,
base: baseBranch
});

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `Translations have been generated and are available in #${newPR.number}.\nPlease merge the translation PR after this PR is merged.`
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body: `Translations have been updated in #${existingPRs[0].number}.`
});
}

- name: Remove label
if: always()
uses: actions/github-script@v7
with:
script: |
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
name: 'TRANSLATE DOCUSAURUS'
});
} catch (error) {
core.warning(`Could not remove label: ${error.message}`);
}
4 changes: 4 additions & 0 deletions docs/7d2d-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ services:

import InlineVoucher from '@site/src/components/InlineVoucher';



This is a test change

<InlineVoucher />

## The Console
Expand Down