diff --git a/.github/scripts/update-palette.py b/.github/scripts/update-palette.py new file mode 100644 index 000000000..45bdea790 --- /dev/null +++ b/.github/scripts/update-palette.py @@ -0,0 +1,14 @@ +import json +import urllib.request + +url = "https://github.com/catppuccin/palette/raw/v0.3.0/palette.json" + +with urllib.request.urlopen(url) as response: + flavors = json.loads(response.read().decode())["flavors"] + +for flavor in flavors: + with open(f"lua/catppuccin/palettes/{flavor}.lua", "w") as f: + f.write("return {\n") + for accent in flavors[flavor]: + f.write(f'\t{accent} = "{flavors[flavor][accent]["hex"]}",\n') + f.write("}\n") diff --git a/.github/workflows/palette.yml b/.github/workflows/palette.yml index c138bff20..0408b16a6 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