-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (109 loc) · 3.1 KB
/
maintenance.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
name: Repository maintenance
on:
schedule:
- cron: '0 0 * * *'
workflow_call:
inputs:
CLEAN:
description: "Clean unused images"
required: false
default: true
type: boolean
DRY_RUN:
description: "Dry run"
required: false
default: false
type: boolean
BRANCH:
type: string
description: 'Branch to push changes to'
required: false
default: 'main'
UPDATE_REQUIREMENTS:
description: "Update requirements"
required: false
default: true
type: boolean
OPTIMIZE_IMAGES:
description: "Optimize images"
required: false
default: true
type: boolean
secrets:
GH_PAT:
required: true
author_email:
required: false
description: "The author email"
author_name:
required: false
description: "The author name"
jobs:
unused_images:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install python
run: uv python install
- name: Install dependencies
run: |
uv sync
- name: Clean
if: inputs.CLEAN
run: |
echo "Cleaning"
pipenv run python .github/find_unused_image.py
- name: Commit
if: inputs.CLEAN && inputs.DRY_RUN == false
uses: actions-js/push@master
with:
github_token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN}}
author_email: ${{ secrets.AUTHOR_EMAIL || 'github-actions[bot]@users.noreply.github.com' }}
author_name: ${{ secrets.AUTHOR_NAME || 'github-actions[bot]' }}
branch: ${{ inputs.BRANCH }}
update-requirements:
runs-on: ubuntu-latest
if: inputs.UPDATE_REQUIREMENTS
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
cache-dependency-glob: "uv.lock"
- name: Install python
run: uv python install
- name: Install dependencies
run: uv sync --no-dev
- name: Update lock
run: uv lock --upgrade
- name: Commit
uses: actions-js/push@master
with:
github_token: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN}}
author_email: ${{ secrets.AUTHOR_EMAIL || 'github-actions[bot]@users.noreply.github.com' }}
author_name: ${{ secrets.AUTHOR_NAME || 'github-actions[bot]' }}
branch: ${{ github.ref }}
message: "[CI] Update lock"
optimize-images:
runs-on: ubuntu-latest
if: inputs.OPTIMIZE_IMAGES
steps:
- uses: actions/checkout@v4
- name: optimize
uses: calibreapp/image-actions@main
with:
githubToken: ${{ secrets.GITHUB_TOKEN}}
ignorePaths: "_assets/meta/**"
compressOnly: true
- name: "Commit & push"
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
message: "[CI] Optimize images"