aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/workflow.yml
blob: 273a51445788fe230181e2a6773d1857a9a1e556 (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
32
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
          # Remove everything after the --- so we can regenerate it.
          perl -pi -e 'exit(0) if $_ =~ m/^\-\-\-/' README.md && echo -e "---" >> README.md
          echo -e "\n## Plugins\n" >> README.md
          export TABLE_COLUMNS='{{string.format("[`%s`](%s)", addon.id, (addon.extra and addon.extra.url or addon.url)) .. ((addon.extra and addon.extra.url or addon.url:find("http")) and "*" or "")}},description'
          ./lpm-latest init . --userdir .
          ./lpm-latest list --table "$TABLE_COLUMNS" --header Plugin,Description --type plugin --tag '!language' --status '!core' --userdir . >> README.md
          echo -e "\n## Languages\n" >> README.md
          ./lpm-latest list --table "$TABLE_COLUMNS" --header Language,Description --type plugin --tag 'language' --userdir .  >> README.md
          echo -e "\n## Libraries\n" >> README.md
          ./lpm-latest list --table "$TABLE_COLUMNS" --header Library,Description --type library --userdir .  >> README.md
          ./lpm-latest exec 'common.write("manifest.json", json.encode(json.decode(common.read("manifest.json")), { pretty = true }) .. "\n")' --userdir .
          ./lpm-latest purge --userdir .
          if ! git diff --exit-code -s README.md manifest.json; then
            git config --global user.name "Github Actions" && git config --global user.email "<>"
            git add README.md manifest.json
            git commit -m '[CI] Updated README.md and manifest.json.'
            git push
          fi