1
+ name : Cleanup Docs Preview
2
+
3
+ on :
4
+ pull_request_target :
5
+ types : [closed]
6
+ branches :
7
+ - main
8
+ paths :
9
+ - ' docs/**'
10
+ - ' tools/github_readme_sync/**'
11
+ - ' .github/workflows/cleanup_docs_preview.yml'
12
+
13
+ jobs :
14
+ cleanup_docs_preview :
15
+ name : cleanup-docs-preview
16
+ runs-on : ubuntu-latest
17
+ steps :
18
+ - name : Checkout tbp.monty
19
+ uses : actions/checkout@v4
20
+ with :
21
+ fetch-depth : 0
22
+ lfs : true
23
+ path : tbp.monty
24
+
25
+ - name : Generate cache key
26
+ id : generate_cache_key
27
+ run : |
28
+ mkdir -p ~/tbp
29
+ ln -s $GITHUB_WORKSPACE/tbp.monty ~/tbp/tbp.monty
30
+ shasum -a 256 ~/tbp/tbp.monty/environment_arm64.yml | awk '{print $1}' > ~/tbp/environment_arm64.sha
31
+ shasum -a 256 ~/tbp/tbp.monty/environment.yml | awk '{print $1}' > ~/tbp/environment.sha
32
+ shasum -a 256 ~/tbp/tbp.monty/pyproject.toml | awk '{print $1}' > ~/tbp/pyproject.toml.sha
33
+ echo "monty-${RUNNER_OS}-$(cat ~/tbp/environment_arm64.sha)-$(cat ~/tbp/environment.sha)-$(cat ~/tbp/pyproject.toml.sha)" > ~/tbp/conda_env_cache_key.txt
34
+ echo "conda_env_cache_key_sha=$(cat ~/tbp/conda_env_cache_key.txt | shasum -a 256 | awk '{print $1}')" >> $GITHUB_OUTPUT
35
+
36
+ - name : Set up Python 3.8
37
+ uses : actions/setup-python@v5
38
+ with :
39
+ python-version : " 3.8"
40
+
41
+ - name : Restore cache
42
+ id : restore_cache
43
+ uses : actions/cache/restore@v4
44
+ with :
45
+ path : |
46
+ ~/miniconda
47
+ key : ${{ steps.generate_cache_key.outputs.conda_env_cache_key_sha }}
48
+
49
+ - name : Install miniconda
50
+ if : steps.restore_cache.outputs.cache-hit != 'true'
51
+ run : |
52
+ if [ ! -d ~/miniconda ]
53
+ then
54
+ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda.sh
55
+ bash ~/miniconda.sh -b -p ~/miniconda
56
+ rm ~/miniconda.sh
57
+ fi
58
+
59
+ - name : Create conda environment
60
+ if : steps.restore_cache.outputs.cache-hit != 'true'
61
+ working-directory : tbp.monty
62
+ run : |
63
+ export PATH="$HOME/miniconda/bin:$PATH"
64
+ (conda env list | grep tbp.monty) && conda remove --name tbp.monty --all --yes || true
65
+ conda env create
66
+ source activate tbp.monty
67
+ pip install -e .[dev,github_readme_sync_tool,print_version_tool]
68
+ pip list
69
+ conda list
70
+
71
+ - name : Save cache
72
+ if : steps.restore_cache.outputs.cache-hit != 'true'
73
+ uses : actions/cache/save@v4
74
+ with :
75
+ path : |
76
+ ~/miniconda
77
+ key : ${{ steps.restore_cache.outputs.cache-primary-key }}
78
+
79
+ - name : Get version and branch
80
+ id : preview_info
81
+ uses : ./tbp.monty/.github/actions/get_preview_info
82
+ with :
83
+ user_login : ${{ github.event.pull_request.user.login }}
84
+
85
+ - name : Delete docs preview
86
+ working-directory : tbp.monty
87
+ run : |
88
+ export PATH="$HOME/miniconda/bin:$PATH"
89
+ source activate tbp.monty
90
+ export README_API_KEY=${{ secrets.README_API_KEY }}
91
+ python -m tools.github_readme_sync.cli delete "${{ steps.preview_info.outputs.monty_version }}-${{ steps.preview_info.outputs.branch_name }}"
0 commit comments