添加检查exif信息的工作流, 完善文档 (#299)
All checks were successful
Mark stale issues and pull requests / stale (push) Successful in 5s

* 慕名而来玩玩

* 换格式

把webp格式的图片换成jpg了
似乎github那边的pr没办法预览webp

* 更新两张新图

* 定期更新一下

* Update README.md

* Create README.md with updates and learnings

Added a README file with updates and personal reflections.

* Add files via upload

* 更新嘻嘻

* Initial plan

* Add PR template, EXIF check workflow, and strip-exif workflow

Co-authored-by: Yueosa <172176062+Yueosa@users.noreply.github.com>

* Address code review: reduce exiftool timeout, improve error logging in strip workflow

Co-authored-by: Yueosa <172176062+Yueosa@users.noreply.github.com>

* Security: pin checkout to SHA, add env vars for shell safety, add security comments

Co-authored-by: Yueosa <172176062+Yueosa@users.noreply.github.com>

* Improve PR template with newcomer guidance, friendlier EXIF comment, add beginner guide, update README

Co-authored-by: Yueosa <172176062+Yueosa@users.noreply.github.com>

* Fix PR template links to use absolute GitHub URLs

Co-authored-by: Yueosa <172176062+Yueosa@users.noreply.github.com>

* 修改示例中的 ID 为我自己的ID

* delete(action): 删除没必要的工作流

* fix(action): 删除对strip_exif工作流的描述

* docs(GUIDE): 为 fork, commit 等操作添加了简单说明

* fix(docs): OMG我是猪鼻, 我把仓库地址写错了X_X

* fix: 被 copilot 鞭策了

* 删除拉取请求模板中的描述部分

* 补充推荐使用--depth的妙妙小提示

* - 补充删旧评论机制
- 移除不必要的权限
- 只在图片变更时触发
- 修复fork pr拿不到来源的bug

* 优化拉取请求模板,增加新手指南的可折叠提示

* 更新 check_exif.yml:升级 actions/checkout 到 v5,优化 exiftool 安装逻辑,增强 PR 评论管理

* 到底要不要删掉旧评论呢(哭), Moemu大佬好像是没删的, 豪! 我也不删了!

* 被删除的不必要的权限似乎是必要的

* 修一修代码格式, 压一压行数

* 修正评论格式

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Yueosa <172176062+Yueosa@users.noreply.github.com>
This commit is contained in:
Lian
2026-03-14 15:59:17 +08:00
committed by GitHub
parent 7e206ec6ec
commit 2d7b0f9a06
4 changed files with 293 additions and 0 deletions

22
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View File

@@ -0,0 +1,22 @@
## 📸 Pull Request
<details>
<summary>🌟 第一次提交?点我查看新手说明 / First time? Click to view guide</summary>
请先阅读 [新手指南 / Beginner Guide](https://github.com/Cute-Dress/Dress/blob/main/GUIDE.md) 了解完整流程。
也可以参考 [已合并的 PR](https://github.com/Cute-Dress/Dress/pulls?q=is%3Apr+is%3Amerged) 的写法。
Please read the [Beginner Guide](https://github.com/Cute-Dress/Dress/blob/main/GUIDE.md) for the full workflow.
You can also check [merged PRs](https://github.com/Cute-Dress/Dress/pulls?q=is%3Apr+is%3Amerged) for examples.
</details>
### 检查清单 / Checklist
> 提交前请确认并将 `[ ]` 改为 `[x]`PR 预览页可直接勾选)
> Please confirm each item and change `[ ]` to `[x]` before submitting (you can tick boxes directly in PR preview).
- [ ] 图片已压缩至 1MB 以内 / Images are compressed to under 1MB
- [ ] 已移除图片中的 EXIF 信息(参考 [CONTRIBUTING.md](CONTRIBUTING.md)/ EXIF data has been removed from images (see [CONTRIBUTING.md](CONTRIBUTING.md))
- [ ] 文件夹以 GitHub ID 命名,并放在对应首字母目录下 / Folder is named after my GitHub ID and placed under the correct alphabetical directory
- [ ] 图片为本人原创,未盗用他人作品 / Images are original and not stolen from others

105
.github/workflows/check_exif.yml vendored Normal file
View File

@@ -0,0 +1,105 @@
name: Check Image EXIF Data
on:
pull_request_target:
types: [opened, synchronize, reopened]
paths: ['**/*.jpg', '**/*.jpeg', '**/*.png', '**/*.webp', '**/*.tiff', '**/*.tif', '**/*.heic', '**/*.heif', '**/*.avif', '**/*.gif']
permissions:
contents: read
pull-requests: write
issues: write
concurrency:
group: exif-pr-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
check-exif:
runs-on: ubuntu-latest
steps:
- name: Install exiftool
run: |
command -v exiftool && exit 0
sudo apt-get install -y --no-install-recommends libimage-exiftool-perl \
|| (sudo apt-get update && sudo apt-get install -y --no-install-recommends libimage-exiftool-perl)
- name: Check EXIF in changed images
uses: actions/github-script@v8
with:
script: |
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const os = require('os');
const pr = context.payload.pull_request;
const { owner, repo } = context.repo;
const prNumber = pr.number;
const IMAGE_EXT = /\.(jpe?g|png|webp|tiff?|hei[cf]|avif|gif)$/i;
// 1. Collect changed image files
let changedImages = [], page = 1;
while (true) {
const { data: files } = await github.rest.pulls.listFiles({ owner, repo, pull_number: prNumber, per_page: 100, page });
if (!files.length) break;
for (const f of files) {
if (['added', 'modified', 'renamed', 'copied'].includes(f.status) && IMAGE_EXT.test(f.filename))
changedImages.push(f.filename);
}
if (files.length < 100) break;
page++;
}
if (!changedImages.length) { core.info('No changed images.'); return; }
core.info(`Checking ${changedImages.length} image(s) for EXIF data.`);
// 2. Download & check each image
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'exif-'));
const exifFiles = [], errors = [];
for (const file of changedImages) {
const tmpFile = path.join(tmp, file.replace(/[\\/]/g, '__'));
try {
const { data } = await github.rest.repos.getContent({
owner: pr.head.repo.owner.login, repo: pr.head.repo.name,
path: file, ref: pr.head.sha
});
let raw;
if (!Array.isArray(data) && data.content) raw = Buffer.from(data.content, 'base64');
else if (!Array.isArray(data) && data.download_url) {
const resp = await fetch(data.download_url);
if (!resp.ok) throw new Error(`Download ${resp.status}`);
raw = Buffer.from(await resp.arrayBuffer());
} else throw new Error('Cannot fetch file content');
fs.writeFileSync(tmpFile, raw);
const count = parseInt(execSync(
`exiftool -EXIF:all -S -q -- '${tmpFile.replace(/'/g, "'\\''")}' 2>/dev/null | wc -l`,
{ encoding: 'utf-8', timeout: 10000 }
).trim()) || 0;
if (count > 0) { exifFiles.push(file); core.info(`EXIF found: ${file} (${count} tags)`); }
} catch (e) { core.warning(`Check failed: ${file}: ${e.message}`); errors.push(file); }
finally { try { fs.unlinkSync(tmpFile); } catch {} }
}
try { fs.rmdirSync(tmp); } catch {}
// 3. Report results
if (errors.length) {
core.setFailed(`EXIF check failed for: ${errors.join(', ')}. Please retry or ask a maintainer.`);
return;
}
if (exifFiles.length) {
const fileList = exifFiles.map(f => `- ${f}`).join('\n');
const body = [
'我们检测到以下文件包含 EXIF 信息,请移除 EXIF 数据后再次提交:',
'We detected EXIF data in the following files. Please remove the EXIF data and resubmit:',
'',
fileList,
'',
`📖 [CONTRIBUTING.md](https://github.com/${owner}/${repo}/blob/master/CONTRIBUTING.md)`
].join('\n');
try { await github.rest.issues.createComment({ owner, repo, issue_number: prNumber, body }); }
catch (e) { core.warning(`Cannot comment: ${e.message}. Check repo Settings > Actions > Workflow permissions.`); }
core.setFailed('EXIF data detected. Please remove EXIF data for privacy protection.');
} else {
core.info('No EXIF data found. ✅');
}

160
GUIDE.md Normal file
View File

@@ -0,0 +1,160 @@
# 🌟 新手指南 / Beginner Guide
欢迎来到 Dress 项目!这份指南将帮助你完成第一次 Pull RequestPR
Welcome to the Dress project! This guide will help you complete your first Pull Request (PR).
---
## 📋 提交流程概览 / Submission Workflow Overview
```
Fork 仓库 → 添加你的照片 → 提交 Commit → 发起 Pull Request → 等待审核合并
Fork repo → Add your photos → Commit → Open Pull Request → Wait for review & merge
```
---
## 第一步Fork 仓库 / Step 1: Fork the Repository
> **Fork** = 把别人的仓库「复制」一份到你自己的 GitHub 账号下,让你可以自由修改喵,不会影响原项目喵!
> **Fork** = Creating your own copy of someone else's repository under your GitHub account, so you can freely make changes without affecting the original.
1. 打开 [Dress 仓库页面](https://github.com/Cute-Dress/Dress)
2. 点击页面右上角的 **Fork** 按钮
3. 这会在你的 GitHub 账号下创建一份仓库副本
---
1. Go to the [Dress repository page](https://github.com/Cute-Dress/Dress)
2. Click the **Fork** button at the top right
3. This creates a copy of the repository under your GitHub account
---
## 第二步:添加你的照片 / Step 2: Add Your Photos
> **Commit** = 给你的修改拍一张「快照」,记录你改了什么内容,每次 Commit 都会生成一条历史记录喵!
> **Commit** = Taking a "snapshot" of your changes, recording what you modified. Each commit creates a point in the project history.
### 方法 A直接在 GitHub 网页上传(最简单)/ Method A: Upload via GitHub Web (Easiest)
1. 进入你 Fork 后的仓库页面(`https://github.com/<你的用户名>/Dress`
2. 找到你 GitHub ID 首字母对应的文件夹(如 ID 为 `Yueosa`,则进入 `Y` 文件夹)
3. 点击 **Add file****Create new file**
4. 在文件名栏输入 `你的GitHubID/README.md`(如 `Yueosa/README.md`),这会自动创建文件夹
5. 在文件中随意写一些内容(如自我介绍)
6. 点击 **Commit changes**
7. 再次点击 **Add file****Upload files**,将你的照片上传到刚创建的文件夹中
8. 点击 **Commit changes**
---
1. Go to your forked repository (`https://github.com/<your-username>/Dress`)
2. Navigate to the folder matching the first letter of your GitHub ID (e.g., `Y` for `Yueosa`)
3. Click **Add file****Create new file**
4. Type `YourGitHubID/README.md` (e.g., `Yueosa/README.md`) in the filename field — this auto-creates the folder
5. Write some content (e.g., a brief introduction)
6. Click **Commit changes**
7. Click **Add file****Upload files** again, and upload your photos into the folder you just created
8. Click **Commit changes**
---
### 方法 B使用 Git 命令行 / Method B: Using Git CLI
> **Clone** = 把远程仓库下载到本地电脑。
> **Push** = 把本地的 Commit 上传同步到远程仓库(你的 Fork
> **Clone** = Downloading the remote repository to your local machine.
> **Push** = Uploading your local commits back to the remote repository (your Fork).
```bash
# 1. 克隆你 Fork 的仓库 / Clone your forked repository
# 💡 由于仓库 commit 历史较多,直接 clone 可能较慢。
# 推荐使用 --depth 1 仅拉取最近一次提交,速度更快喵!
# 💡 The repo has a large commit history, so a full clone may be slow.
# Consider using --depth 1 to only fetch the latest commit for a faster download!
git clone --depth 1 https://github.com/<你的用户名>/Dress.git
cd Dress
# 2. 创建你的文件夹并添加照片 / Create your folder and add photos
# 将 <首字母> 替换为你 GitHub ID 的首字母,<你的GitHubID> 替换为你的 GitHub ID
# Replace <FirstLetter> with the first letter of your GitHub ID
mkdir -p <首字母>/<你的GitHubID>
cp /path/to/your/photos/* <首字母>/<你的GitHubID>/
# 3. 提交更改 / Commit your changes
git add .
git commit -m "Add photos for <你的GitHubID>"
# 4. 推送到你的 Fork / Push to your fork
git push origin main
```
---
## 第三步:发起 Pull Request / Step 3: Open a Pull Request
> **Pull RequestPR** = 向原仓库的维护者提出申请:「我在我的 Fork 里做了一些修改,请把它们合并到原项目里吧喵!」
> **Pull Request (PR)** = A request to the original repository's maintainers saying: "I've made some changes in my Fork — please merge them into the original project!"
1. 回到你 Fork 的仓库页面
2. 你会看到一个提示 **"This branch is X commits ahead"**,点击 **Contribute****Open pull request**
3. 填写 PR 模板中的描述和检查清单
4. 点击 **Create pull request**
---
1. Go back to your forked repository page
2. You should see a prompt saying **"This branch is X commits ahead"** — click **Contribute****Open pull request**
3. Fill in the description and checklist in the PR template
4. Click **Create pull request**
---
## 第四步:等待审核 / Step 4: Wait for Review
提交 PR 后,自动化机器人会帮你检查:
- 📏 **文件大小检查**:图片是否在 1MB 以内
- 🔒 **EXIF 信息检查**:图片是否包含隐私元数据
如果检查未通过机器人会留下评论告诉你如何修正。你可以按照提示修改后再次推送pushPR 会自动更新。
维护者审核通过后,你的 PR 就会被合并。恭喜你完成了第一次开源贡献!🎉
---
After submitting the PR, automated bots will check:
- 📏 **File size check**: Are images under 1MB?
- 🔒 **EXIF data check**: Do images contain private metadata?
If any check fails, the bot will leave a comment explaining how to fix it. You can make changes and push again — the PR will update automatically.
Once a maintainer approves, your PR will be merged. Congratulations on your first open-source contribution! 🎉
---
## ⚠️ 提交前请注意 / Before You Submit
1. **压缩图片** — 确保每张图片小于 1MB。可以使用 [TinyPNG](https://tinypng.com/) 等在线工具压缩。
2. **移除 EXIF 信息** — 照片可能包含你的位置、设备等隐私信息。详见 [CONTRIBUTING.md](CONTRIBUTING.md)。
3. **正确命名文件夹** — 使用你的 GitHub ID 命名,并放在对应首字母目录下。
4. **原创图片** — 只提交你自己的照片,不接受盗图。
---
1. **Compress images** — Make sure each image is under 1MB. Use tools like [TinyPNG](https://tinypng.com/).
2. **Remove EXIF data** — Photos may contain your location, device info, etc. See [CONTRIBUTING.md](CONTRIBUTING.md).
3. **Name your folder correctly** — Use your GitHub ID and place it under the matching alphabetical directory.
4. **Original images only** — Only submit your own photos. Stolen images are not accepted.
---
## 🔗 参考链接 / Useful Links
- [项目说明 / Project README](README.md)
- [贡献指南 / Contributing Guide](CONTRIBUTING.md)
- [项目详细说明 / Detailed README](README_DETAIL.md)
- [已合并的 PR 参考 / Merged PRs for reference](https://github.com/Cute-Dress/Dress/pulls?q=is%3Apr+is%3Amerged)

View File

@@ -74,3 +74,9 @@ This repository is licensed under a Creative Commons Attribution-NonCommercial-S
请仔细阅读[CONTRIBUTING.md](CONTRIBUTING.md) 请仔细阅读[CONTRIBUTING.md](CONTRIBUTING.md)
Please read [CONTRIBUTING.md](CONTRIBUTING.md) carefully. Please read [CONTRIBUTING.md](CONTRIBUTING.md) carefully.
### 新手指南 / Beginner Guide
第一次参与?请阅读 [新手指南 / Beginner Guide](GUIDE.md),了解完整的 Fork → 提交 → PR 流程。
First time contributing? Read the [Beginner Guide](GUIDE.md) for a step-by-step walkthrough of the Fork → Commit → PR workflow.