nonicons.nvim/.github/workflows/sync.yaml

72 lines
2.4 KiB
YAML

name: sync
on:
schedule:
- cron: '0 8 * * *'
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
sync-mapping:
name: Sync Upstream Mapping
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Generate mapping from upstream
run: |
curl -sL https://raw.githubusercontent.com/ya2s/nonicons/main/src/template/nonicon.json \
| jq -r 'to_entries | sort_by(.key) | .[] | "\(.key | sub("-16$"; "")) \(.value)"' \
> /tmp/upstream.txt
{
echo '---@type table<string, integer>'
echo 'local M = {'
while IFS=' ' read -r name code; do
printf " ['%s'] = %s,\n" "$name" "$code"
done < /tmp/upstream.txt
echo '}'
echo 'return M'
} > lua/nonicons/mapping.lua
- name: Generate colors from nvim-web-devicons
run: |
sudo apt-get install -y -qq lua5.4 > /dev/null
curl -sL https://raw.githubusercontent.com/nvim-tree/nvim-web-devicons/master/lua/nvim-web-devicons/default/icons_by_file_extension.lua \
-o /tmp/devicons_ext.lua
curl -sL https://raw.githubusercontent.com/nvim-tree/nvim-web-devicons/master/lua/nvim-web-devicons/default/icons_by_filename.lua \
-o /tmp/devicons_fname.lua
lua5.4 scripts/gen-colors.lua > lua/nonicons/colors.lua
- name: Check for changes
id: diff
run: |
if git diff --quiet lua/nonicons/mapping.lua lua/nonicons/colors.lua; then
echo "changed=false" >> "$GITHUB_OUTPUT"
else
echo "changed=true" >> "$GITHUB_OUTPUT"
fi
- name: Create pull request
if: steps.diff.outputs.changed == 'true'
uses: peter-evans/create-pull-request@v7
with:
branch: sync/upstream
title: 'fix: sync with upstream nonicons font and devicons colors'
body: |
## Problem
`mapping.lua` or `colors.lua` is out of sync with upstream sources.
## Solution
Auto-generated from upstream [ya2s/nonicons](https://github.com/ya2s/nonicons) `nonicon.json`
and [nvim-web-devicons](https://github.com/nvim-tree/nvim-web-devicons) color definitions.
commit-message: 'fix: sync with upstream nonicons font and devicons colors'
labels: upstream-sync
delete-branch: true