New YiCAT updates #2076
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# GitHub CI build pipeline | |
name: All 4.x Doc JSON Files | |
on: | |
push: | |
branches: | |
- 'master' | |
pull_request: | |
branches: | |
- 'master' | |
jobs: | |
build: | |
strategy: | |
matrix: | |
platform: [flutter, ios, macos, electron, unity, rn] | |
working_dir: [../dita/RTC-NG, ../en-US/dita/RTC-NG] | |
runs-on: ubuntu-latest | |
name: ${{matrix.platform}} ${{matrix.working_dir == '../en-US/dita/RTC-NG' && '(en)' || '(cn)'}} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up python 3.8 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.8' | |
- name: Set Language | |
id: matrix_vars | |
run: | | |
if [[ ${{ matrix.working_dir }} == *en-US* ]]; then | |
echo "language=en" >> $GITHUB_OUTPUT | |
echo "filename=${{matrix.platform}}_en_ng.json" >> $GITHUB_OUTPUT | |
else | |
echo "language=cn" >> $GITHUB_OUTPUT | |
echo "filename=${{matrix.platform}}_cn_ng.json" >> $GITHUB_OUTPUT | |
fi | |
- name: Get branch name | |
id: branch-name | |
uses: tj-actions/branch-names@v7 | |
- name: Install dependencies | |
run: | | |
cd xml2json | |
python -m pip install --upgrade pip | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: Run ${{steps.matrix_vars.outputs.language}} JSON creation | |
run: | | |
cd xml2json | |
python xml2json.py --working_dir ${{matrix.working_dir}} --platform_tag ${{matrix.platform}}\ | |
--json_file ${{steps.matrix_vars.outputs.filename}}\ | |
--language ${{steps.matrix_vars.outputs.language}} | |
- name: Validate and Order JSON File | |
run: jq 'sort_by(.'id')' "xml2json/${{steps.matrix_vars.outputs.filename}}" > ${{steps.matrix_vars.outputs.filename}} | |
- name: Upload ${{matrix.platform}} ${{steps.matrix_vars.outputs.language}} Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{matrix.platform}}_ng_json_template_${{steps.matrix_vars.outputs.language}}.json | |
path: ${{steps.matrix_vars.outputs.filename}} | |
- name: Upload ${{matrix.platform}} NG ${{steps.matrix_vars.outputs.language}} JSON to release | |
if: github.ref_name == github.event.repository.default_branch | |
uses: svenstaro/[email protected] | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: ${{steps.matrix_vars.outputs.filename}} | |
asset_name: ${{matrix.platform}}_ng_json_template_${{steps.matrix_vars.outputs.language}}.json | |
tag: ${{steps.branch-name.outputs.current_branch}}-build | |
overwrite: true | |
body: "Template file for automatic comment population." | |
check_changed_files: | |
name: Check xml2json updated | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
outputs: | |
updated_xml: ${{steps.xml2json-changed.outputs.updated_xml}} | |
steps: | |
- name: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v37 | |
- name: Output Bool | |
id: xml2json-changed | |
run: echo "updated_xml=${{contains(steps.changed-files.outputs.all_changed_files, 'xml2json/xml2json.py')}}" >> $GITHUB_OUTPUT | |
compare: | |
name: Compare JSON Files | |
needs: [check_changed_files, build] | |
if: needs.check_changed_files.outputs.updated_xml | |
permissions: | |
pull-requests: read | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
platform: [flutter, ios, macos, electron, unity, rn] | |
language: [en, cn] | |
steps: | |
- name: Set up python 3.9 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Download DocC Archive ⬇️ | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{matrix.platform}}_ng_json_template_${{matrix.language}}.json | |
path: artifacts | |
- name: Download current release | |
uses: robinraju/[email protected] | |
with: | |
tag: "master-build" | |
fileName: ${{matrix.platform}}_ng_json_template_${{matrix.language}}.json | |
- name: Check Sort by ID | |
run: | | |
# Sorting and moving newly generated JSON | |
jq 'sort_by(.'id')' "artifacts/${{matrix.platform}}_${{matrix.language}}_ng.json" > ${{matrix.platform}}_${{matrix.language}}_new.json | |
# mv artifacts/${{matrix.platform}}_${{matrix.language}}_ng.json ${{matrix.platform}}_${{matrix.language}}_new.json | |
# Sorting and moving latest release JSON | |
jq 'sort_by(.'id')' "${{matrix.platform}}_ng_json_template_${{matrix.language}}.json" > ${{matrix.platform}}_${{matrix.language}}_old.json | |
- name: Make Diff Compare File | |
run: | | |
set -e; diff -u ${{matrix.platform}}_${{matrix.language}}_old.json ${{matrix.platform}}_${{matrix.language}}_new.json -U 3 | tee comparison.txt > /dev/null | |
- name: Output Diff | |
run: | | |
if [[ ! -s comparison.txt ]]; then | |
echo "No differences found." | |
else | |
echo """ | |
\`\`\`diff | |
$(cat comparison.txt) | |
\`\`\` | |
""" >> $GITHUB_STEP_SUMMARY | |
fi |