Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Get and update primer primitives automatically #253

Merged
merged 7 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/workflows/update-colors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Get/Update Primer Color Primitives

env:
_DEST_DIR: '${{ github.workspace }}/lua/github-theme/palette/primitives'
_JSON_DIR: '${{ github.workspace }}/node_modules/@primer/primitives/dist/json/colors'
_LICENSE_GLOB: '${{ github.workspace }}/node_modules/@primer/primitives/[Ll][Ii][Cc][Ee][Nn][Ss][Ee]*'
_PRIMITIVES_PKGJSON: '${{ github.workspace }}/node_modules/@primer/primitives/package.json'

on:
workflow_dispatch:
schedule:
# 3x per week (every other day) at 12:40pm Pacific Time
- cron: '40 19 * * 1,3,5'

jobs:
get-colors:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: lts
check-latest: true

- run: npm i @primer/primitives@latest

- run: |
set -u +f
shopt -s nocaseglob failglob
license="$(<$_LICENSE_GLOB)"
rm -r "$_DEST_DIR" || :
mkdir -p "$_DEST_DIR"
cd "$_JSON_DIR"
if jq -e .version "$_PRIMITIVES_PKGJSON"; then
version="M._VERSION = vim.json.decode([=[$(jq -e .version "$_PRIMITIVES_PKGJSON")]=], { luanil = { object = false, array = false } })"
fi
for file in *.json; do
cat >|"${_DEST_DIR}/${file%.json}.lua" <<EOF
-- NOTE: THIS IS AN AUTO-GENERATED FILE. DO NOT EDIT BY-HAND.
local M = vim.json.decode([=[$(<"$file")]=], { luanil = { object = false, array = false } })
${version-}
M._LICENSE = [=[
$license]=]
return M
EOF
done
- run: make fmt

- uses: peter-evans/create-pull-request@v5
with:
commit-message: Update color primitives
branch: update-color-primitives
delete-branch: true
title: Update color primitives
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ doc/tags
test/plenary
.repro
misc
node_modules/
18 changes: 18 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "github-nvim-theme",
"private": true,
"dependencies": {
"@primer/primitives": "^7.11.10"
}
}