diff --git a/.github/workflows/update-colors.yml b/.github/workflows/update-colors.yml new file mode 100644 index 00000000..cb47edf8 --- /dev/null +++ b/.github/workflows/update-colors.yml @@ -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" <