48 lines
1.2 KiB
Markdown
48 lines
1.2 KiB
Markdown
# Gitea Release Attachments Cleaner
|
|
|
|
A Node.js script to manage and clean up release attachments in Gitea repositories. This tool helps maintain repository size by keeping only the N most recent release attachments and removing older ones.
|
|
|
|
## Prerequisites
|
|
|
|
- Node.js installed on your system
|
|
- Access to a Gitea instance
|
|
- Personal access token with repository access permissions
|
|
|
|
## Configuration
|
|
|
|
Edit the `config` object in `index.js`:
|
|
|
|
```javascript
|
|
const config = {
|
|
GITEA_URL: "https://git.zeldon.ru",
|
|
GITEA_TOKEN: "", // Your Gitea personal access token
|
|
REPO_OWNER: "", // Repository owner (user or organization)
|
|
REPO_NAME: "", // Repository name
|
|
KEEP_LAST_N: 10, // Number of latest attachments to keep
|
|
};
|
|
```
|
|
|
|
## Usage
|
|
|
|
1. Clone this repository
|
|
2. Run the script:
|
|
```bash
|
|
node index.js
|
|
```
|
|
|
|
The script will:
|
|
|
|
1. List all attachments and their total size
|
|
2. Show how many attachments will be kept and deleted
|
|
3. Ask for confirmation before deletion
|
|
4. Delete the selected attachments and show progress
|
|
|
|
Example output:
|
|
|
|
```
|
|
Found 25 total attachments (156.78 MB)
|
|
Keeping 10 most recent attachments (52.30 MB)
|
|
15 attachments will be deleted (104.48 MB)
|
|
Do you want to proceed with deletion? (y/N)
|
|
```
|