Skip to content

Update Unicode Data

Update Unicode Data #7

name: Update Unicode Data
on:
workflow_dispatch: # Can be triggered manually
schedule:
- cron: '0 0 1 */3 *' # Run at midnight on the 1st of every 3rd month
permissions:
contents: write
pull-requests: write
jobs:
update-unicode-data:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup mise
uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
- name: Install dependencies
run: dart pub get
- name: Generate GitHub App token
id: generate-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
app-id: ${{ secrets.UNICODE_UPDATE_APP_ID }}
private-key: ${{ secrets.UNICODE_UPDATE_PRIVATE_KEY }}
- name: Run Unicode Data Updater
run: dart run tools/unicode_data_updater.dart
- name: Run Normalizer Generator
run: dart run tools/normalizer_gen.dart
- name: Check for changes
id: git-check
run: |
if [[ -n $(git status --porcelain) ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
else
echo "changes=false" >> $GITHUB_OUTPUT
fi
- name: Create branch and commit changes
if: steps.git-check.outputs.changes == 'true'
run: |
# Generate branch name
BRANCH_NAME="unicode-data-update-$(date +'%Y-%m-%d')"
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
# Configure git
git config --global user.name "GitHub Actions Bot"
git config --global user.email "actions@github.com"
# Create a branch
git checkout -b $BRANCH_NAME
# Add and commit changes
git add .
git commit -m "Update Unicode data and normalization files"
# Push branch
git push origin $BRANCH_NAME
- name: Create Pull Request
if: steps.git-check.outputs.changes == 'true'
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
run: |
gh pr create \
--title "Update Unicode Data and Normalization Files" \
--body "This PR updates the Unicode data files and regenerates normalization data. Updated data files in data/ directory and regenerated normalization data. This PR was automatically created by GitHub Actions." \
--base master \
--head "$BRANCH_NAME"