image-optimizer-node 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +224 -2
- package/action.yml +257 -0
- package/dist/cli.cjs +3155 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +3128 -0
- package/dist/index.cjs +2899 -0
- package/dist/index.d.cts +414 -0
- package/dist/index.d.ts +414 -0
- package/dist/index.js +2807 -0
- package/docs/AI/SKILL.md +73 -0
- package/package.json +83 -4
- package/schemas/imgopt.config.schema.json +236 -0
- package/templates/workflows/optimize-images.yml +64 -0
package/docs/AI/SKILL.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# image-optimizer-node AI Skill & Integration Guide
|
|
2
|
+
|
|
3
|
+
> 本文档专供 AI 编程助手与开发者查阅,包含核心 API 签名、CLI 命令、最佳实践与避坑指南。
|
|
4
|
+
|
|
5
|
+
## 1. 模块定位与核心能力
|
|
6
|
+
- **定位**:围绕 `imgopt` (`Image-Optimizer-Cli`) 构建的通用 Node.js 图片优化工具、TypeScript SDK 与 GitHub Action,支持自动探测目录生成配置、基于双哈希清单的幂等增量优化(绝不重复处理)、原图保留/还原以及跨平台 `imgopt` CLI 二进制自动下载校验。
|
|
7
|
+
- **源码路径**:`$SDK_ROOT_DIR/image-optimizer-node`
|
|
8
|
+
- **依赖声明**:`git+https://github.com/xzsean666/image-optimizer-node.git#<commit-hash>`
|
|
9
|
+
|
|
10
|
+
## 2. 导出清单与核心 API (API Reference)
|
|
11
|
+
|
|
12
|
+
### 核心函数(`src/index.ts`)
|
|
13
|
+
- `initProject(options?: InitOptions): Promise<InitResult>` — 自动探测项目结构(`src/assets`、`public`、`static`、`docs/images`、Monorepo workspaces 等)并生成 `imgopt.config.json`。
|
|
14
|
+
- `optimizeProject(options?: OptimizeCommandOptions): Promise<OptimizeRunReport>` — 执行增量优化;内置双哈希清单跳过已优化文件、默认备份原图至 `.imgopt/originals`、参数变更时优先从原图无损重压。
|
|
15
|
+
- `checkProject(options?: CheckCommandOptions): Promise<CheckResult>` — CI 只读门禁检查(检测未优化图片与 `budgets` 违规)。
|
|
16
|
+
- `restoreOriginals(options?: RestoreCommandOptions): Promise<RestoreResult>` — 从备份目录还原原图并清理对应转换产物/清单记录。
|
|
17
|
+
- `cleanProject(options?: CleanCommandOptions): Promise<CleanResult>` — 清理已删除图片对应的孤儿备份与无效清单项。
|
|
18
|
+
- `doctorProject(options?: DoctorCommandOptions): Promise<DoctorReport>` — 检查配置、CLI 状态、备份、清单与 `.gitignore` 健康状况。
|
|
19
|
+
- `ensureCli(options?: EnsureCliOptions): Promise<CliBinaryInfo>` / `downloadCliRelease(...)` / `getCliStatus(...)` — 管理底层 `imgopt` 二进制的下载、`.sha256` 校验与本地缓存。
|
|
20
|
+
- `loadConfig` / `normalizeConfig` / `detectProject` / `resolveEffectiveOptimization` — 配置与目录探测底层能力。
|
|
21
|
+
|
|
22
|
+
### 主要配置项(`ImgoptConfig`)
|
|
23
|
+
- `cli`: `{ repo, version ('latest' | 'vX.Y.Z'), autoDownload, autoUpdate, cacheDir?, binPath?, downloadBaseUrl? }`
|
|
24
|
+
- `targets`: `Array<{ dir, include?, exclude? }>`
|
|
25
|
+
- `backup`: `{ enabled (默认 true), dir (默认 '.imgopt/originals'), strategy ('preserve-first' | 'keep-initial') }`
|
|
26
|
+
- `manifest`: `string`(默认 `'.imgopt/manifest.json'`)
|
|
27
|
+
- `optimization`: `{ preset, quality (默认 0.95), effort (默认 5), format (默认 'preserve'), preserveMetadata, preserveIcc, convertToSrgb, resize?, minBytes, minSavingsPercent, removeSourceOnFormatChange }`
|
|
28
|
+
- `rules`: `Array<{ match, optimization }>`
|
|
29
|
+
- `budgets`: `{ maxFileSizeKb?, maxWidth?, maxHeight? }`
|
|
30
|
+
|
|
31
|
+
## 3. 快速上手完整用例 (Quickstart)
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
import {
|
|
35
|
+
initProject,
|
|
36
|
+
optimizeProject,
|
|
37
|
+
checkProject,
|
|
38
|
+
} from 'image-optimizer-node';
|
|
39
|
+
|
|
40
|
+
await initProject({
|
|
41
|
+
projectRoot: process.cwd(),
|
|
42
|
+
backup: true,
|
|
43
|
+
ci: true,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const report = await optimizeProject({
|
|
47
|
+
projectRoot: process.cwd(),
|
|
48
|
+
dryRun: false,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
console.log(report.summary);
|
|
52
|
+
|
|
53
|
+
const check = await checkProject({ projectRoot: process.cwd() });
|
|
54
|
+
if (!check.ok) {
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### CLI 常用命令
|
|
60
|
+
```bash
|
|
61
|
+
imgopt-node init --ci --gitignore
|
|
62
|
+
imgopt-node optimize
|
|
63
|
+
imgopt-node optimize --staged
|
|
64
|
+
imgopt-node check
|
|
65
|
+
imgopt-node restore --all
|
|
66
|
+
imgopt-node cli update --cli-version latest --force
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 4. 常见陷阱与最佳实践 (Pitfalls & Best Practices)
|
|
70
|
+
1. **避免与 Rust 原生 `imgopt` 混淆**:本包的 CLI 命令是 `imgopt-node`,底层下载并调度 `imgopt` 执行编解码,不要在代码里绕过 `manifest.json` 直接对同一原目录反复覆盖运行 `imgopt optimize`。
|
|
71
|
+
2. **保留扩展名安全**:对已有代码引用的项目,`optimization.format` 保持默认 `'preserve'`;只有明确接受后缀变为 `.webp`/`.avif` 且已同步处理代码引用时,才在全局或 `rules` 中设置 `'webp'` / `'auto'`。
|
|
72
|
+
3. **关闭备份时的参数修改**:当 `backup.enabled: false` 且修改了压缩参数,默认会跳过已优化图片防止二次有损画质下降;除非确认可接受重编码,才显式传 `reprocessOnConfigChange: true`。
|
|
73
|
+
4. **GitHub Action 控制 CLI 版本**:使用 `uses: xzsean666/image-optimizer-node@main` 时,默认 `cli-version: 'latest'` 会先解析真实最新 release tag 再命中/刷新 `actions/cache`,确保新发布的 `imgopt` 自动生效;如需强制重新下载可设 `force-download-cli: true`。
|
package/package.json
CHANGED
|
@@ -1,6 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "image-optimizer-node",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Production-grade Node.js CLI, SDK, and GitHub Action wrapper around imgopt (Image-Optimizer-Cli) with auto-init config, idempotent dual-hash deduplication, and original image backup/restore.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/xzsean666/image-optimizer-node.git"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=20.0.0"
|
|
16
|
+
},
|
|
17
|
+
"packageManager": "pnpm@12.15.0",
|
|
18
|
+
"bin": {
|
|
19
|
+
"imgopt-node": "./dist/cli.js",
|
|
20
|
+
"image-optimizer-node": "./dist/cli.js"
|
|
21
|
+
},
|
|
22
|
+
"main": "./dist/index.cjs",
|
|
23
|
+
"module": "./dist/index.js",
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/index.d.cts",
|
|
33
|
+
"default": "./dist/index.cjs"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"./schema": "./schemas/imgopt.config.schema.json"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist",
|
|
40
|
+
"schemas",
|
|
41
|
+
"templates",
|
|
42
|
+
"action.yml",
|
|
43
|
+
"README.md",
|
|
44
|
+
"docs"
|
|
45
|
+
],
|
|
46
|
+
"scripts": {
|
|
47
|
+
"build": "tsup && node -e \"try{require('fs').chmodSync('dist/cli.js',0o755)}catch{}\"",
|
|
48
|
+
"dev": "tsup --watch",
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"lint": "tsc --noEmit --noUnusedLocals --noUnusedParameters",
|
|
51
|
+
"test": "vitest run",
|
|
52
|
+
"test:unit": "vitest run test/unit",
|
|
53
|
+
"test:e2e": "vitest run test/e2e",
|
|
54
|
+
"test:watch": "vitest"
|
|
55
|
+
},
|
|
56
|
+
"keywords": [
|
|
57
|
+
"image-optimizer",
|
|
58
|
+
"imgopt",
|
|
59
|
+
"webp",
|
|
60
|
+
"avif",
|
|
61
|
+
"png",
|
|
62
|
+
"jpeg",
|
|
63
|
+
"gif",
|
|
64
|
+
"oxipng",
|
|
65
|
+
"ssim",
|
|
66
|
+
"cli",
|
|
67
|
+
"github-action",
|
|
68
|
+
"incremental"
|
|
69
|
+
],
|
|
70
|
+
"dependencies": {
|
|
71
|
+
"adm-zip": "^0.5.16",
|
|
72
|
+
"commander": "^13.1.0",
|
|
73
|
+
"picocolors": "^1.1.1",
|
|
74
|
+
"picomatch": "^4.0.2",
|
|
75
|
+
"tar": "^7.4.3"
|
|
76
|
+
},
|
|
77
|
+
"devDependencies": {
|
|
78
|
+
"@types/adm-zip": "^0.5.8",
|
|
79
|
+
"@types/node": "^22.15.0",
|
|
80
|
+
"@types/picomatch": "^4.0.0",
|
|
81
|
+
"tsup": "^8.5.0",
|
|
82
|
+
"typescript": "^5.8.0",
|
|
83
|
+
"vitest": "^3.1.0"
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://raw.githubusercontent.com/xzsean666/image-optimizer-node/main/schemas/imgopt.config.schema.json",
|
|
4
|
+
"title": "image-optimizer-node Configuration",
|
|
5
|
+
"description": "Configuration file for imgopt-node (image-optimizer-node).",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": ["targets"],
|
|
8
|
+
"additionalProperties": false,
|
|
9
|
+
"properties": {
|
|
10
|
+
"$schema": {
|
|
11
|
+
"type": "string"
|
|
12
|
+
},
|
|
13
|
+
"version": {
|
|
14
|
+
"type": "integer",
|
|
15
|
+
"const": 1,
|
|
16
|
+
"default": 1
|
|
17
|
+
},
|
|
18
|
+
"cli": {
|
|
19
|
+
"type": "object",
|
|
20
|
+
"additionalProperties": false,
|
|
21
|
+
"properties": {
|
|
22
|
+
"repo": {
|
|
23
|
+
"type": "string",
|
|
24
|
+
"default": "xzsean666/Image-Optimizer-Cli",
|
|
25
|
+
"description": "GitHub owner/repo hosting imgopt releases."
|
|
26
|
+
},
|
|
27
|
+
"version": {
|
|
28
|
+
"type": "string",
|
|
29
|
+
"default": "latest",
|
|
30
|
+
"description": "Target imgopt release tag (e.g. 'latest' or 'v0.1.2')."
|
|
31
|
+
},
|
|
32
|
+
"autoDownload": {
|
|
33
|
+
"type": "boolean",
|
|
34
|
+
"default": true,
|
|
35
|
+
"description": "Automatically download imgopt CLI if missing locally."
|
|
36
|
+
},
|
|
37
|
+
"autoUpdate": {
|
|
38
|
+
"type": "boolean",
|
|
39
|
+
"default": false,
|
|
40
|
+
"description": "Automatically check and update to newer CLI release on run when version is 'latest'."
|
|
41
|
+
},
|
|
42
|
+
"cacheDir": {
|
|
43
|
+
"type": "string",
|
|
44
|
+
"description": "Custom directory to cache downloaded imgopt binaries."
|
|
45
|
+
},
|
|
46
|
+
"binPath": {
|
|
47
|
+
"type": "string",
|
|
48
|
+
"description": "Explicit local path to an imgopt binary."
|
|
49
|
+
},
|
|
50
|
+
"downloadBaseUrl": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "Optional custom mirror base URL for downloading release assets."
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"targets": {
|
|
57
|
+
"type": "array",
|
|
58
|
+
"minItems": 1,
|
|
59
|
+
"description": "Asset directories to scan and optimize.",
|
|
60
|
+
"items": {
|
|
61
|
+
"type": "object",
|
|
62
|
+
"required": ["dir"],
|
|
63
|
+
"additionalProperties": false,
|
|
64
|
+
"properties": {
|
|
65
|
+
"dir": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "Directory path relative to project root."
|
|
68
|
+
},
|
|
69
|
+
"include": {
|
|
70
|
+
"type": "array",
|
|
71
|
+
"items": { "type": "string" },
|
|
72
|
+
"default": ["**/*.{png,jpg,jpeg,webp,avif,gif}"]
|
|
73
|
+
},
|
|
74
|
+
"exclude": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"items": { "type": "string" },
|
|
77
|
+
"default": ["**/favicon*.*", "**/apple-touch-icon*.*"]
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
"backup": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"additionalProperties": false,
|
|
85
|
+
"properties": {
|
|
86
|
+
"enabled": {
|
|
87
|
+
"type": "boolean",
|
|
88
|
+
"default": true,
|
|
89
|
+
"description": "Whether to preserve unoptimized original images before optimization."
|
|
90
|
+
},
|
|
91
|
+
"dir": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"default": ".imgopt/originals",
|
|
94
|
+
"description": "Directory where original image backups are stored."
|
|
95
|
+
},
|
|
96
|
+
"strategy": {
|
|
97
|
+
"type": "string",
|
|
98
|
+
"enum": ["preserve-first", "keep-initial"],
|
|
99
|
+
"default": "preserve-first",
|
|
100
|
+
"description": "Backup update behavior when an asset is modified."
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"manifest": {
|
|
105
|
+
"type": "string",
|
|
106
|
+
"default": ".imgopt/manifest.json",
|
|
107
|
+
"description": "Path to incremental deduplication manifest JSON."
|
|
108
|
+
},
|
|
109
|
+
"optimization": {
|
|
110
|
+
"$ref": "#/$defs/optimizationOptions"
|
|
111
|
+
},
|
|
112
|
+
"rules": {
|
|
113
|
+
"type": "array",
|
|
114
|
+
"description": "Per-glob optimization overrides.",
|
|
115
|
+
"items": {
|
|
116
|
+
"type": "object",
|
|
117
|
+
"required": ["match", "optimization"],
|
|
118
|
+
"additionalProperties": false,
|
|
119
|
+
"properties": {
|
|
120
|
+
"match": {
|
|
121
|
+
"oneOf": [
|
|
122
|
+
{ "type": "string" },
|
|
123
|
+
{ "type": "array", "items": { "type": "string" }, "minItems": 1 }
|
|
124
|
+
]
|
|
125
|
+
},
|
|
126
|
+
"optimization": {
|
|
127
|
+
"$ref": "#/$defs/optimizationOptions"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"budgets": {
|
|
133
|
+
"type": "object",
|
|
134
|
+
"additionalProperties": false,
|
|
135
|
+
"properties": {
|
|
136
|
+
"maxFileSizeKb": {
|
|
137
|
+
"type": "number",
|
|
138
|
+
"minimum": 1
|
|
139
|
+
},
|
|
140
|
+
"maxWidth": {
|
|
141
|
+
"type": "integer",
|
|
142
|
+
"minimum": 1
|
|
143
|
+
},
|
|
144
|
+
"maxHeight": {
|
|
145
|
+
"type": "integer",
|
|
146
|
+
"minimum": 1
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
"$defs": {
|
|
152
|
+
"optimizationOptions": {
|
|
153
|
+
"type": "object",
|
|
154
|
+
"additionalProperties": false,
|
|
155
|
+
"properties": {
|
|
156
|
+
"preset": {
|
|
157
|
+
"type": "string",
|
|
158
|
+
"enum": ["balanced", "maximum", "aggressive"],
|
|
159
|
+
"default": "balanced"
|
|
160
|
+
},
|
|
161
|
+
"quality": {
|
|
162
|
+
"type": "number",
|
|
163
|
+
"minimum": 0,
|
|
164
|
+
"maximum": 1,
|
|
165
|
+
"default": 0.95,
|
|
166
|
+
"description": "Target perceptual SSIM score (0.0 to 1.0)."
|
|
167
|
+
},
|
|
168
|
+
"effort": {
|
|
169
|
+
"type": "integer",
|
|
170
|
+
"minimum": 1,
|
|
171
|
+
"maximum": 6,
|
|
172
|
+
"default": 5
|
|
173
|
+
},
|
|
174
|
+
"format": {
|
|
175
|
+
"type": "string",
|
|
176
|
+
"enum": [
|
|
177
|
+
"preserve",
|
|
178
|
+
"webp",
|
|
179
|
+
"avif",
|
|
180
|
+
"auto",
|
|
181
|
+
"jpeg",
|
|
182
|
+
"png",
|
|
183
|
+
"gif",
|
|
184
|
+
"force-webp",
|
|
185
|
+
"force-avif"
|
|
186
|
+
],
|
|
187
|
+
"default": "preserve"
|
|
188
|
+
},
|
|
189
|
+
"preserveMetadata": {
|
|
190
|
+
"type": "boolean",
|
|
191
|
+
"default": false
|
|
192
|
+
},
|
|
193
|
+
"preserveIcc": {
|
|
194
|
+
"type": "boolean",
|
|
195
|
+
"default": false
|
|
196
|
+
},
|
|
197
|
+
"convertToSrgb": {
|
|
198
|
+
"type": "boolean",
|
|
199
|
+
"default": true
|
|
200
|
+
},
|
|
201
|
+
"resize": {
|
|
202
|
+
"type": "object",
|
|
203
|
+
"additionalProperties": false,
|
|
204
|
+
"properties": {
|
|
205
|
+
"maxWidth": { "type": "integer", "minimum": 1 },
|
|
206
|
+
"maxHeight": { "type": "integer", "minimum": 1 },
|
|
207
|
+
"mode": {
|
|
208
|
+
"type": "string",
|
|
209
|
+
"enum": ["scale-down", "contain", "cover", "exact"],
|
|
210
|
+
"default": "scale-down"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
"concurrency": {
|
|
215
|
+
"type": "integer",
|
|
216
|
+
"minimum": 1
|
|
217
|
+
},
|
|
218
|
+
"minBytes": {
|
|
219
|
+
"type": "integer",
|
|
220
|
+
"minimum": 0,
|
|
221
|
+
"default": 1024
|
|
222
|
+
},
|
|
223
|
+
"minSavingsPercent": {
|
|
224
|
+
"type": "number",
|
|
225
|
+
"minimum": 0,
|
|
226
|
+
"maximum": 100,
|
|
227
|
+
"default": 1
|
|
228
|
+
},
|
|
229
|
+
"removeSourceOnFormatChange": {
|
|
230
|
+
"type": "boolean",
|
|
231
|
+
"default": true
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
name: Optimize Images
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
paths:
|
|
7
|
+
- "imgopt.config.json"
|
|
8
|
+
- "src/assets/**"
|
|
9
|
+
- "public/**"
|
|
10
|
+
- "assets/**"
|
|
11
|
+
- "static/**"
|
|
12
|
+
- "images/**"
|
|
13
|
+
- "docs/**/images/**"
|
|
14
|
+
pull_request:
|
|
15
|
+
paths:
|
|
16
|
+
- "imgopt.config.json"
|
|
17
|
+
- "src/assets/**"
|
|
18
|
+
- "public/**"
|
|
19
|
+
- "assets/**"
|
|
20
|
+
- "static/**"
|
|
21
|
+
- "images/**"
|
|
22
|
+
workflow_dispatch:
|
|
23
|
+
inputs:
|
|
24
|
+
cli_version:
|
|
25
|
+
description: "imgopt CLI version to download ('latest' or tag e.g. 'v0.1.2')"
|
|
26
|
+
type: string
|
|
27
|
+
default: "latest"
|
|
28
|
+
force_download_cli:
|
|
29
|
+
description: "Force re-downloading imgopt CLI ignoring cache"
|
|
30
|
+
type: boolean
|
|
31
|
+
default: false
|
|
32
|
+
mode:
|
|
33
|
+
description: "Mode: optimize or check"
|
|
34
|
+
type: choice
|
|
35
|
+
options:
|
|
36
|
+
- optimize
|
|
37
|
+
- check
|
|
38
|
+
default: optimize
|
|
39
|
+
commit:
|
|
40
|
+
description: "Commit optimized assets back to branch"
|
|
41
|
+
type: boolean
|
|
42
|
+
default: true
|
|
43
|
+
|
|
44
|
+
permissions:
|
|
45
|
+
contents: write
|
|
46
|
+
|
|
47
|
+
concurrency:
|
|
48
|
+
group: optimize-images-${{ github.ref }}
|
|
49
|
+
cancel-in-progress: false
|
|
50
|
+
|
|
51
|
+
jobs:
|
|
52
|
+
optimize:
|
|
53
|
+
runs-on: ubuntu-latest
|
|
54
|
+
steps:
|
|
55
|
+
- name: Checkout repository
|
|
56
|
+
uses: actions/checkout@v4
|
|
57
|
+
|
|
58
|
+
- name: Run image-optimizer-node
|
|
59
|
+
uses: xzsean666/image-optimizer-node@main
|
|
60
|
+
with:
|
|
61
|
+
cli-version: ${{ inputs.cli_version || 'latest' }}
|
|
62
|
+
force-download-cli: ${{ inputs.force_download_cli || 'false' }}
|
|
63
|
+
mode: ${{ github.event_name == 'pull_request' && 'check' || (inputs.mode || 'optimize') }}
|
|
64
|
+
commit: ${{ github.event_name == 'pull_request' && 'false' || (inputs.commit != '' && inputs.commit || 'true') }}
|