generated from Enveloppe/template-netlify-vercel
-
Notifications
You must be signed in to change notification settings - Fork 0
54 lines (53 loc) · 1.86 KB
/
update_req_clean_medias.yml
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
name: update requirements and clean unused images
on:
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
jobs:
update-requirements:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
cache: 'pip'
- name: Get .env file
uses: xom9ikk/dotenv@master
with:
path: .github
load_mode: strict
- name: install pur
run: pip install pur
- name: Update requirements.txt
if: ${{ env.WORKFLOW_TYPE == 'netlify'}}
run: pur -r requirements.txt --skip obsidiantools
- name: Update requirements.txt
if: ${{ env.WORKFLOW_TYPE != 'netlify'}}
run: pur -r requirements.txt
- name: check python cache
id: python_cache
uses: actions/cache@v3
with:
path: venv
key: pip-${{ steps.setup_python.outputs.python-version }}-${{ hashFiles('requirements.txt') }}
- if: steps.python_cache.outputs.cache-hit != 'true'
name: Recreate python cache
run: |
if [ -d "venv" ]; then rm -rf venv; fi
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- if: ${{ env.CLEAN == 'true' }} && ${{ env.DRY_RUN == 'false' }}
name: Remove unused media
run: python find_unused_media.py "$IMG_DIR"
- if: ${{ env.CLEAN == 'true'}} && ${{ env.DRY_RUN == 'true' }}
name: Dry run
run: python find_unused_media.py "$IMG_DIR" --dry-run
- name: commit the new change (if found)
continue-on-error: true
run: |
git config --global user.name 'github-actions'
git config --global user.email '[email protected]'
git commit -am "Update requirements & remove unused media"
git push