Update lexicons #361
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
name: Update lexicons | |
permissions: {} | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 3 * * *' | |
workflow_dispatch: {} | |
merge_group: {} | |
jobs: | |
main: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref || github.ref_name }} | |
- uses: pnpm/action-setup@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: 📦 Install dependencies | |
run: pnpm install --frozen-lockfile | |
- name: 📦 Update lexicons | |
run: pnpm --filter @tsky/lexicons build | |
- name: ✅ Check if lexicons version was updated | |
id: check-version-change | |
run: echo "VERSION_CHANGED=$(pnpm run --silent --filter @tsky/lexicons check-version-change)" >> "$GITHUB_OUTPUT" | |
- name: 🔼 Create PR to update lexicons | |
if: ${{ steps.check-version-change.outputs.VERSION_CHANGED == 'yes' }} | |
env: | |
BRANCH_NAME: gh-actions-update-lexicons | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git diff --quiet || ( | |
git switch --create $BRANCH_NAME && | |
git add . && | |
git commit -m "chore: update lexicons.ts" | |
) | |
git push -u origin $BRANCH_NAME | |
gh pr create \ | |
--title 'chore: Update lexicons' \ | |
--body 'This PR is made via GitHub Actions workflow ([update-lexicons.yml](https://github.com/tsky-dev/tsky/blob/main/.github/workflows/update-lexicons.yml)) automatically.' |