Skip to content

Commit f48af20

Browse files
committed
remove deprecated deployment workflows for API and frontend
add deployment workflow for marking translations and deploying frontend/backend add script to mark outdated translations add workflow for marking stale translations
1 parent 4fde018 commit f48af20

File tree

2 files changed

+204
-0
lines changed

2 files changed

+204
-0
lines changed
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
#!/usr/bin/env node
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
6+
const WARNING_BANNERS = {
7+
'es': `:::warning La traducción puede estar desactualizada
8+
La versión en inglés de este documento se actualizó recientemente. Es posible que esta traducción aún no refleje esos cambios.
9+
10+
¡Ayuda a mantener nuestras traducciones actualizadas! Si hablas este idioma con fluidez, considera revisar la [versión en inglés](ENGLISH_DOC_LINK) y actualizar esta traducción.
11+
:::
12+
13+
`,
14+
'pt-BR': `:::warning A tradução pode estar desatualizada
15+
A versão em inglês deste documento foi atualizada recentemente. Esta tradução pode não refletir essas alterações ainda.
16+
17+
Ajude-nos a manter nossas traduções atualizadas! Se você é fluente neste idioma, considere revisar a [versão em inglês](ENGLISH_DOC_LINK) e atualizar esta tradução.
18+
:::
19+
20+
`,
21+
};
22+
23+
const DEFAULT_WARNING = `:::warning Translation May Be Outdated
24+
The English version of this document was recently updated. This translation may not reflect those changes yet.
25+
26+
Please help keep our translations up to date! If you're fluent in this language, consider reviewing the [English version](ENGLISH_DOC_LINK) and updating this translation.
27+
:::
28+
29+
`;
30+
31+
const WARNING_MARKER = ':::warning';
32+
33+
const changedFilesPath = path.join(process.cwd(), 'changed_english_docs.txt');
34+
if (!fs.existsSync(changedFilesPath)) {
35+
console.log('No changed English docs file found');
36+
process.exit(0);
37+
}
38+
39+
const changedEnglishDocs = fs.readFileSync(changedFilesPath, 'utf8')
40+
.trim()
41+
.split('\n')
42+
.filter(line => line.trim().length > 0);
43+
44+
if (changedEnglishDocs.length === 0) {
45+
console.log('No changed English docs to process');
46+
process.exit(0);
47+
}
48+
49+
const i18nDir = path.join(process.cwd(), 'frontend', 'i18n');
50+
if (!fs.existsSync(i18nDir)) {
51+
console.log('No i18n directory found');
52+
process.exit(0);
53+
}
54+
55+
const languages = fs.readdirSync(i18nDir).filter(item => {
56+
const itemPath = path.join(i18nDir, item);
57+
return fs.statSync(itemPath).isDirectory();
58+
});
59+
60+
console.log(`Found ${languages.length} language directories: ${languages.join(', ')}`);
61+
62+
let totalFilesMarked = 0;
63+
const markedFiles = [];
64+
65+
changedEnglishDocs.forEach(englishDocPath => {
66+
const relativePath = englishDocPath.replace('frontend/docs/', '');
67+
const englishDocLink = `/docs/${relativePath.replace('.md', '')}`;
68+
69+
console.log(`\nProcessing: ${englishDocPath}`);
70+
console.log(` Relative path: ${relativePath}`);
71+
72+
languages.forEach(lang => {
73+
const translationPath = path.join(
74+
i18nDir,
75+
lang,
76+
'docusaurus-plugin-content-docs',
77+
'current',
78+
relativePath
79+
);
80+
81+
if (!fs.existsSync(translationPath)) {
82+
console.log(` [${lang}] Translation does not exist, skipping`);
83+
return;
84+
}
85+
86+
let content = fs.readFileSync(translationPath, 'utf8');
87+
88+
if (content.includes(WARNING_MARKER)) {
89+
console.log(` [${lang}] Already has outdated warning, skipping`);
90+
return;
91+
}
92+
93+
let frontmatterEnd = 0;
94+
if (content.startsWith('---')) {
95+
const secondDelimiter = content.indexOf('---', 3);
96+
if (secondDelimiter !== -1) {
97+
frontmatterEnd = secondDelimiter + 3;
98+
}
99+
}
100+
101+
const warningBanner = WARNING_BANNERS[lang] || DEFAULT_WARNING;
102+
const warningWithLink = warningBanner.replace('ENGLISH_DOC_LINK', englishDocLink);
103+
104+
let updatedContent;
105+
if (frontmatterEnd > 0) {
106+
const frontmatter = content.substring(0, frontmatterEnd);
107+
const restOfContent = content.substring(frontmatterEnd).trimStart();
108+
updatedContent = `${frontmatter}\n\n${warningWithLink}${restOfContent}`;
109+
} else {
110+
const restOfContent = content.trimStart();
111+
updatedContent = `${warningWithLink}${restOfContent}`;
112+
}
113+
114+
fs.writeFileSync(translationPath, updatedContent, 'utf8');
115+
console.log(` [${lang}] ✓ Marked as outdated`);
116+
totalFilesMarked++;
117+
markedFiles.push(translationPath.replace(process.cwd() + path.sep, '').replace(/\\/g, '/'));
118+
});
119+
});
120+
121+
console.log(`\n✅ Total files marked: ${totalFilesMarked}`);
122+
123+
if (markedFiles.length > 0) {
124+
const markedFilesPath = path.join(process.cwd(), 'marked_translation_files.txt');
125+
fs.writeFileSync(markedFilesPath, markedFiles.join('\n'), 'utf8');
126+
console.log(`Marked files list written to: ${markedFilesPath}`);
127+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Mark Stale Translations
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
mark-translations:
13+
name: Mark translations outdated
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Set up Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: '18'
26+
27+
- name: Get changed English documentation files
28+
id: changed-files
29+
run: |
30+
set -euo pipefail
31+
BEFORE="${{ github.event.before }}"
32+
if git rev-parse "$BEFORE^{commit}" >/dev/null 2>&1; then
33+
DIFF_BASE="$BEFORE"
34+
else
35+
DIFF_BASE=""
36+
fi
37+
38+
if [ -n "$DIFF_BASE" ]; then
39+
CHANGED_FILES=$(git diff --name-only "$DIFF_BASE" "${{ github.sha }}" | grep "^frontend/docs/.*\.md$" || true)
40+
else
41+
CHANGED_FILES=$(git ls-tree --name-only -r "${{ github.sha }}" | grep "^frontend/docs/.*\.md$" || true)
42+
fi
43+
44+
if [ -z "$CHANGED_FILES" ]; then
45+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
46+
else
47+
printf '%s\n' "$CHANGED_FILES" > changed_english_docs.txt
48+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
49+
fi
50+
51+
- name: Mark translations as outdated
52+
if: steps.changed-files.outputs.has_changes == 'true'
53+
run: |
54+
node .github/workflows/scripts/mark-translations-outdated.js
55+
56+
- name: Check if translations were modified
57+
if: steps.changed-files.outputs.has_changes == 'true'
58+
id: check-changes
59+
run: |
60+
if [ -n "$(git status --porcelain)" ]; then
61+
echo "translations_modified=true" >> "$GITHUB_OUTPUT"
62+
else
63+
echo "translations_modified=false" >> "$GITHUB_OUTPUT"
64+
fi
65+
66+
- name: Commit changes
67+
if: steps.check-changes.outputs.translations_modified == 'true'
68+
run: |
69+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
70+
git config --local user.name "github-actions[bot]"
71+
git add frontend/i18n/
72+
git commit -m "Mark translations as potentially outdated (post-merge)"
73+
74+
- name: Push changes
75+
if: steps.check-changes.outputs.translations_modified == 'true'
76+
run: |
77+
git push origin HEAD:${{ github.ref }}

0 commit comments

Comments
 (0)