-
-
Notifications
You must be signed in to change notification settings - Fork 106
70 lines (59 loc) · 2.12 KB
/
update-color-primitives.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
permissions:
checks: write
contents: write
issues: write
packages: read
pull-requests: write
statuses: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
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
- uses: JohnnyMorganz/stylua-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: -f stylua.toml --verify -- ${{ env._DEST_DIR }}
- uses: peter-evans/create-pull-request@v6
with:
commit-message: Update color primitives
branch: update-color-primitives
delete-branch: true
title: Update color primitives