Skip to content

Commit b4c7528

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 consolidate translation marking workflow into deploy process
1 parent 4fde018 commit b4c7528

File tree

2 files changed

+191
-1
lines changed

2 files changed

+191
-1
lines changed

.github/workflows/deploy-web.yml

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ on:
55
branches:
66
- master
77

8+
permissions:
9+
contents: write
10+
811
jobs:
912
deploy:
1013
name: Deploy frontend
@@ -16,7 +19,67 @@ jobs:
1619
workflow_id: 42688838
1720
access_token: ${{ github.token }}
1821

19-
- uses: actions/checkout@v4
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Set up Node.js
28+
uses: actions/setup-node@v4
29+
with:
30+
node-version: '18'
31+
32+
- name: Get changed English documentation files
33+
id: changed-files
34+
run: |
35+
set -euo pipefail
36+
BEFORE="${{ github.event.before }}"
37+
if git rev-parse "$BEFORE^{commit}" >/dev/null 2>&1; then
38+
DIFF_BASE="$BEFORE"
39+
else
40+
DIFF_BASE=""
41+
fi
42+
43+
if [ -n "$DIFF_BASE" ]; then
44+
CHANGED_FILES=$(git diff --name-only "$DIFF_BASE" "${{ github.sha }}" | grep "^frontend/docs/.*\.md$" || true)
45+
else
46+
CHANGED_FILES=$(git ls-tree --name-only -r "${{ github.sha }}" | grep "^frontend/docs/.*\.md$" || true)
47+
fi
48+
49+
if [ -z "$CHANGED_FILES" ]; then
50+
echo "has_changes=false" >> "$GITHUB_OUTPUT"
51+
else
52+
printf '%s\n' "$CHANGED_FILES" > changed_english_docs.txt
53+
echo "has_changes=true" >> "$GITHUB_OUTPUT"
54+
fi
55+
56+
- name: Mark translations as outdated
57+
if: steps.changed-files.outputs.has_changes == 'true'
58+
run: |
59+
node .github/workflows/scripts/mark-translations-outdated.js
60+
61+
- name: Check if translations were modified
62+
if: steps.changed-files.outputs.has_changes == 'true'
63+
id: check-changes
64+
run: |
65+
if [ -n "$(git status --porcelain)" ]; then
66+
echo "translations_modified=true" >> "$GITHUB_OUTPUT"
67+
else
68+
echo "translations_modified=false" >> "$GITHUB_OUTPUT"
69+
fi
70+
71+
- name: Commit changes
72+
if: steps.check-changes.outputs.translations_modified == 'true'
73+
run: |
74+
git config --local user.email "omp-bot@users.noreply.github.com"
75+
git config --local user.name "omp-bot"
76+
git add frontend/i18n/
77+
git commit -m "Mark translations as potentially outdated (post-merge)"
78+
79+
- name: Push changes
80+
if: steps.check-changes.outputs.translations_modified == 'true'
81+
run: |
82+
git push origin HEAD:${{ github.ref }}
2083
2184
- name: Cache ~/.npm for npm ci
2285
uses: actions/cache@v4
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+
}

0 commit comments

Comments
 (0)