-
-
Notifications
You must be signed in to change notification settings - Fork 12
71 lines (61 loc) · 1.98 KB
/
check-localization.yml
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
name: Check Localization Changes
on:
pull_request:
paths:
- 'src/languages/*.json'
- 'src/localize/string.json'
workflow_dispatch:
permissions:
contents: read
issues: write
pull-requests: write
jobs:
check-localization:
runs-on: ubuntu-latest
env:
hasIssues: false
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'
- name: Install dependencies
run: npm install json5
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v34
- name: Filter changed localization files
id: filtered-files
run: |
filtered_files=$(echo "${{ steps.changed-files.outputs.all_changed_files }}" | tr ' ' '\n' | grep '^src/languages/.*\.json$' || true)
echo "filtered_files<<EOF" >> $GITHUB_ENV
echo "$filtered_files" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Run localization check
id: check-localization
run: node scripts/check-localization.js $filtered_files
- name: Check if diff-report.md exists
id: check-diff-report
run: |
if [ -f scripts/diff-report.md ]; then
echo "hasIssues=true" >> $GITHUB_ENV
fi
- name: Add PR comment if there are issues
if: env.hasIssues == 'true'
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const diffReport = fs.readFileSync('scripts/diff-report.md', 'utf8');
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: diffReport
});
- name: Fail if there are issues
if: env.hasIssues == 'true'
run: exit 1