Skip to content

Commit 20a949d

Browse files
authored
Merge pull request projekt0n#253 from tmillr/ci-update-colors
ci: Get and update primer primitives automatically
2 parents 7c1ed06 + 3f324ef commit 20a949d

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed

.github/workflows/update-colors.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Get/Update Primer Color Primitives
2+
3+
env:
4+
_DEST_DIR: '${{ github.workspace }}/lua/github-theme/palette/primitives'
5+
_JSON_DIR: '${{ github.workspace }}/node_modules/@primer/primitives/dist/json/colors'
6+
_LICENSE_GLOB: '${{ github.workspace }}/node_modules/@primer/primitives/[Ll][Ii][Cc][Ee][Nn][Ss][Ee]*'
7+
_PRIMITIVES_PKGJSON: '${{ github.workspace }}/node_modules/@primer/primitives/package.json'
8+
9+
on:
10+
workflow_dispatch:
11+
schedule:
12+
# 3x per week (every other day) at 12:40pm Pacific Time
13+
- cron: '40 19 * * 1,3,5'
14+
15+
jobs:
16+
get-colors:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- uses: actions/setup-node@v3
22+
with:
23+
node-version: lts
24+
check-latest: true
25+
26+
- run: npm i @primer/primitives@latest
27+
28+
- run: |
29+
set -u +f
30+
shopt -s nocaseglob failglob
31+
license="$(<$_LICENSE_GLOB)"
32+
rm -r "$_DEST_DIR" || :
33+
mkdir -p "$_DEST_DIR"
34+
cd "$_JSON_DIR"
35+
36+
if jq -e .version "$_PRIMITIVES_PKGJSON"; then
37+
version="M._VERSION = vim.json.decode([=[$(jq -e .version "$_PRIMITIVES_PKGJSON")]=], { luanil = { object = false, array = false } })"
38+
fi
39+
40+
for file in *.json; do
41+
cat >|"${_DEST_DIR}/${file%.json}.lua" <<EOF
42+
-- NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT EDIT BY-HAND.
43+
local M = vim.json.decode([=[$(<"$file")]=], { luanil = { object = false, array = false } })
44+
${version-}
45+
M._LICENSE = [=[
46+
$license]=]
47+
return M
48+
EOF
49+
done
50+
51+
- run: make fmt
52+
53+
- uses: peter-evans/create-pull-request@v5
54+
with:
55+
commit-message: Update color primitives
56+
branch: update-color-primitives
57+
delete-branch: true
58+
title: Update color primitives

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ doc/tags
22
test/plenary
33
.repro
44
misc
5+
node_modules/

package-lock.json

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "github-nvim-theme",
3+
"private": true,
4+
"dependencies": {
5+
"@primer/primitives": "^7.11.10"
6+
}
7+
}

0 commit comments

Comments
 (0)