summaryrefslogtreecommitdiff
path: root/.github/workflows/docs_cleanup.yml
blob: 0260b64748e1a9f1943ac303c8689623c512c8ec (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: documentation cleanup
on:
  schedule:
    - cron: '0 1 * * SUN'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Install Packages
        run: |
          sudo apt-get update
          sudo apt-get install -y python3 python3-jinja2

      - name: Setup Deploy Key
        env:
            SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        run: |
            ssh-agent -a $SSH_AUTH_SOCK > /dev/null
            ssh-add - <<< "${{ secrets.CVC5_DOCS_TOKEN }}"

      - name: Clone docs repo
        env:
            SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        run: |
          git config --global user.email "docbot@cvc5"
          git config --global user.name "DocBot"
          git clone git@github.com:cvc5/docs-ci.git target/
      
      - name: Remove stale docs
        run: |
          cd target
          for file in `find ./ -maxdepth 1 -name "docs-*"`; do
            mod=`git log -1 HEAD --pretty="%ci" $file`
            touch -d "$mod" $file
          done
          find ./ -maxdepth 1 -name "docs-*" -mtime +7 -exec git rm -r {} +
          git commit -m "Prune docs" || echo "Nothing to prune"

      - name: Squash old commits
        env:
            SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        run: |
          cd target
          git log
          first=`git rev-list --max-parents=0 HEAD`
          last=`git rev-list --until=1.month.ago -n1 HEAD`
          git rebase -Xtheirs --onto $first $last
          git log
      
      - name: Push
        env:
            SSH_AUTH_SOCK: /tmp/ssh_agent.sock
        run: |
          cd target

          python3 genindex.py
          git add README.md
          git commit -m "Update README.md"

          git push -f
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback