Ignore zip files for docs upload diff (#7322)
[cvc5.git] / .github / workflows / docs_cleanup.yml
1 name: documentation cleanup
2 on:
3 schedule:
4 - cron: '0 1 * * *'
5
6 jobs:
7 docs-cleanup:
8 runs-on: ubuntu-latest
9 if: github.repository == 'cvc5/cvc5'
10 steps:
11 - name: Install Packages
12 run: |
13 sudo apt-get update
14 sudo apt-get install -y python3 python3-jinja2
15
16 - name: Setup Deploy Key
17 env:
18 SSH_AUTH_SOCK: /tmp/ssh_agent.sock
19 run: |
20 ssh-agent -a $SSH_AUTH_SOCK > /dev/null
21 ssh-add - <<< "${{ secrets.CVC5_DOCS_TOKEN }}"
22
23 - name: Clone docs repo
24 env:
25 SSH_AUTH_SOCK: /tmp/ssh_agent.sock
26 run: |
27 git config --global user.email "docbot@cvc5"
28 git config --global user.name "DocBot"
29 git clone git@github.com:cvc5/docs-ci.git target/
30
31 - name: Remove stale docs
32 run: |
33 cd target
34 for file in `find ./ -maxdepth 1 -name "docs-*"`; do
35 mod=`git log -1 HEAD --pretty="%ai" $file`
36 touch -d "$mod" $file
37 done
38 find ./ -maxdepth 1 -name "docs-*" -mtime +7 -exec git rm -r {} +
39 find ./ -maxdepth 1 -name "docs-*" -xtype l -exec git rm {} +
40 git commit -m "Prune docs" || echo "Nothing to prune"
41
42 - name: Squash old commits
43 env:
44 SSH_AUTH_SOCK: /tmp/ssh_agent.sock
45 run: |
46 cd target
47 first=`git rev-list --max-parents=0 HEAD`
48 cutoff=`date -d "-1 month" +%Y-%m-%d`
49 last=`git log --pretty='%as %H' | awk -v cutoff=$cutoff '$1 < cutoff { print $2 }' | head -n1`
50 if [ -n "$last" ]; then
51 git checkout $last
52 ts=`git log -1 --format=%ct`
53 git reset --soft $first
54 if git diff --cached --exit-code
55 then
56 echo "Nothing to squash"
57 else
58 git commit -m "Squash old history" --date=$ts
59 fi
60 git cherry-pick $last..main
61 fi
62
63 - name: Push
64 env:
65 SSH_AUTH_SOCK: /tmp/ssh_agent.sock
66 run: |
67 cd target
68
69 python3 genindex.py
70 git add README.md
71 if git diff --cached --exit-code
72 then
73 echo "Nothing changed"
74 else
75 git commit -m "Update README.md"
76 fi
77
78 git push -f origin HEAD:main