From b901cf144573b293b6cefeb1ac8c97d5d239ee7a Mon Sep 17 00:00:00 2001 From: winston Date: Thu, 28 Dec 2023 12:11:57 +0100 Subject: [PATCH] ci: update palette workflow for `@catppuccin/palette@v1.0.0` (#570) --- .github/scripts/update-palette.py | 14 ++++++++++++++ .github/workflows/palette.yml | 11 +---------- 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 .github/scripts/update-palette.py diff --git a/.github/scripts/update-palette.py b/.github/scripts/update-palette.py new file mode 100644 index 00000000..dbf773fa --- /dev/null +++ b/.github/scripts/update-palette.py @@ -0,0 +1,14 @@ +import json +import urllib.request + +url = "https://github.com/catppuccin/palette/raw/main/palette.json" + +with urllib.request.urlopen(url) as response: + flavors = json.loads(response.read().decode()) + +for flavor in flavors: + with open(f"lua/catppuccin/palettes/{flavor}.lua", "w") as f: + f.write("return {\n") + for color in flavors[flavor]["colors"]: + f.write(f'\t{color} = "{flavors[flavor]["colors"][color]["hex"]}",\n') + f.write("}\n") diff --git a/.github/workflows/palette.yml b/.github/workflows/palette.yml index c138bff2..0408b16a 100644 --- a/.github/workflows/palette.yml +++ b/.github/workflows/palette.yml @@ -13,16 +13,7 @@ jobs: - uses: actions/checkout@v3 - name: Make changes to pull request - run: | - curl -o /tmp/palette.json https://raw.githubusercontent.com/catppuccin/palette/main/palette.json - python -c "import json - data = json.load(open('/tmp/palette.json')) - - for flavour in data: - with open('lua/catppuccin/palettes/{flavour}.lua'.format(flavour = flavour), 'w') as f: - f.write('return {\n') - for accent in data[flavour]: f.write('\t{accent} = \"{hex}\",\n'.format(accent = accent, hex = data[flavour][accent]['hex'])) - f.write('}\n')" + run: python3 ./.github/scripts/update-palette.py - name: Create Pull Request id: cpr