aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/workflow.yml
blob: 87df3a4e38317f08580e775077a3799f36326c98 (plain)
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
name: Update README

on:
  push:
    branches: [master]

jobs:
  reorganize:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Generate table with `lpm`
        run: |
          wget https://github.com/lite-xl/lite-xl-plugin-manager/releases/download/latest/lpm.x86_64-linux -O lpm-latest && chmod +x lpm-latest
          # Unstub all stubs so we can make proper previews.
          ./lpm-latest --userdir . init . && ./lpm-latest --userdir . color install "*" && ./lpm-latest purge --userdir .
          ./lpm-latest exec scripts/make_preview_image.lua colors/*
          # Remove everything after the --- so we can regenerate it.
          perl -pi -e 'exit(0) if $_ =~ m/^\-\-\-/' README.md
          echo "---" >> README.md
          echo -e "\n## Dark\n" >> README.md
          ./lpm-latest list --repository . --type color --tag "dark" --table '{{string.format("[%s](%s)", addon.id, addon.url)}},{{string.format("![%s_preview](previews/%s.svg)", addon.id,addon.id)}}' --type color --header Theme,Preview >> README.md
          echo -e "\n## Light\n" >> README.md
          ./lpm-latest list --repository . --type color --tag "light" --table '{{string.format("[%s](%s)", addon.id, addon.url)}},{{string.format("![%s_preview](previews/%s.svg)", addon.id,addon.id)}}' --type color --header Theme,Preview >> README.md
          if ! git diff --exit-code -s README.md; then
            git config --global user.name "Github Actions" && git config --global user.email "<>"
            git add README.md previews
            git commit -m '[CI] Updated README.md.'
            git push
          fi