Skip to content

Sync OpenCC Dictionary Data from Upstream #4

Sync OpenCC Dictionary Data from Upstream

Sync OpenCC Dictionary Data from Upstream #4

Workflow file for this run

name: Sync OpenCC Dictionary Data from Upstream
on:
workflow_dispatch:
inputs:
upstream_ref:
description: 'Commit ID or Tag from byvoid/OpenCC'
required: true
default: 'master'
version:
description: 'New version number for package.json'
required: true
jobs:
update-data:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout current repository
uses: actions/checkout@v4
- name: Checkout byvoid/OpenCC
uses: actions/checkout@v4
with:
repository: byvoid/OpenCC
ref: ${{ github.event.inputs.upstream_ref }}
path: upstream-opencc
- name: Sync upstream data files
run: |
# Sync only upstream dictionary text files. This repository tracks
# upstream-authored data and does not generate reverse dictionaries.
rsync -av --delete \
--include='*/' \
--include='*.txt' \
--exclude='*' \
upstream-opencc/data/dictionary/ \
data/
find data -mindepth 1 -type f ! -name '*.txt' -delete
find data -mindepth 1 -type d -empty -delete
mkdir -p test-data
cp upstream-opencc/test/testcases/testcases.json test-data/testcases.json
# Remove the upstream clone to clean up
rm -rf upstream-opencc
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Update package.json version
run: |
npm version "${{ github.event.inputs.version }}" --no-git-tag-version || \
echo "::warning::Skipping package.json version update because '${{ github.event.inputs.version }}' is not a valid npm version."
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
commit-message: "chore: update data from byvoid/OpenCC@${{ github.event.inputs.upstream_ref }} to version ${{ github.event.inputs.version }}"
title: "Sync dictionary data from byvoid/OpenCC@${{ github.event.inputs.upstream_ref }}"
body: |
Automated sync from upstream.
- Upstream ref: `${{ github.event.inputs.upstream_ref }}`
- New version: `${{ github.event.inputs.version }}`
branch: sync-data
base: main