깃 디스코드 연동
nodejs 설치 필요. 가이드 참조
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,3 +13,4 @@
|
|||||||
Assets/_Recovery
|
Assets/_Recovery
|
||||||
Assets/_Recovery.meta
|
Assets/_Recovery.meta
|
||||||
GameData/Backups
|
GameData/Backups
|
||||||
|
.claude/settings.local.json
|
||||||
|
|||||||
63
DISCORD_HOOK_GUIDE.md
Normal file
63
DISCORD_HOOK_GUIDE.md
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# Git Discord Notification Hook
|
||||||
|
|
||||||
|
Send commit notifications to Discord with Korean text support.
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
- **Node.js** (required for Korean text support)
|
||||||
|
- Download from: https://nodejs.org/
|
||||||
|
- Install the LTS version
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
1. **Open your project folder**
|
||||||
|
|
||||||
|
2. **Run the setup script:**
|
||||||
|
```powershell
|
||||||
|
.\setup-hooks.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
3. **Configure your Discord webhook URL:**
|
||||||
|
- Open `git-hooks/send-discord.js` in a text editor (Notepad, VS Code, etc.)
|
||||||
|
- Find line with `webhookUrl =`
|
||||||
|
- Replace the URL with your Discord webhook URL
|
||||||
|
- Save the file
|
||||||
|
- Run `.\setup-hooks.ps1` again to apply changes
|
||||||
|
|
||||||
|
**That's it!** Now every commit will send a notification to Discord.
|
||||||
|
|
||||||
|
## How to Get Discord Webhook URL
|
||||||
|
|
||||||
|
1. Open your Discord server settings
|
||||||
|
2. Go to **Integrations** → **Webhooks**
|
||||||
|
3. Click **New Webhook**
|
||||||
|
4. Copy the **Webhook URL**
|
||||||
|
5. Paste it into `git-hooks/send-discord.js`
|
||||||
|
|
||||||
|
## What Gets Sent to Discord
|
||||||
|
|
||||||
|
- Commit hash
|
||||||
|
- Author name
|
||||||
|
- Commit message (supports Korean/other languages)
|
||||||
|
- List of changed files
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
**Hook not running?**
|
||||||
|
- Make sure you ran `.\setup-hooks.ps1` after cloning the repo
|
||||||
|
- Check that `.git/hooks/post-commit` file exists
|
||||||
|
|
||||||
|
**Korean text showing as `???`?**
|
||||||
|
- Make sure Node.js is installed
|
||||||
|
- Run `node --version` in terminal to check
|
||||||
|
|
||||||
|
**Hook sending errors?**
|
||||||
|
- Verify your Discord webhook URL is correct
|
||||||
|
- Check that the webhook has permission to send messages
|
||||||
|
|
||||||
|
## Uninstalling
|
||||||
|
|
||||||
|
Run this to remove the hooks:
|
||||||
|
```bash
|
||||||
|
rm .git/hooks/post-commit .git/hooks/send-discord.js
|
||||||
|
```
|
||||||
3
git-hooks/post-commit
Normal file
3
git-hooks/post-commit
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd "$(git rev-parse --show-toplevel)" || exit 1
|
||||||
|
node .git/hooks/send-discord.js
|
||||||
57
git-hooks/send-discord.js
Normal file
57
git-hooks/send-discord.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const https = require('https');
|
||||||
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
|
process.env.LANG = 'en_US.UTF-8';
|
||||||
|
process.env.LC_ALL = 'en_US.UTF-8';
|
||||||
|
process.env.GIT_PAGER = '';
|
||||||
|
|
||||||
|
const webhookUrl = 'https://discordapp.com/api/webhooks/1467361257693642918/6KByhX070Cw1Y5-fHjOgxI-AtXfFyxZKMIv0QeGts8bR9Z6YzQHmsmHKvoLCOxj-SmwX';
|
||||||
|
|
||||||
|
const shortHash = execSync('git rev-parse --short HEAD', { encoding: 'utf8' }).toString().trim();
|
||||||
|
const commitAuthor = execSync('git show -s --format=%an HEAD', { encoding: 'utf8' }).toString().trim();
|
||||||
|
const commitMessage = execSync('git log -1 --pretty=%B', { encoding: 'utf8' }).toString().trim();
|
||||||
|
|
||||||
|
const repoName = 'Northbound';
|
||||||
|
|
||||||
|
const embed = {
|
||||||
|
title: `New Commit: ${repoName}`,
|
||||||
|
color: 5814783,
|
||||||
|
description: commitMessage,
|
||||||
|
fields: [
|
||||||
|
{ name: 'Commit', value: shortHash, inline: true },
|
||||||
|
{ name: 'Author', value: commitAuthor, inline: true },
|
||||||
|
{ name: 'Changed Files', value: 'No files', inline: false }
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
const data = JSON.stringify({ embeds: [embed] });
|
||||||
|
|
||||||
|
const url = new URL(webhookUrl);
|
||||||
|
const options = {
|
||||||
|
hostname: url.hostname,
|
||||||
|
path: url.pathname + url.search,
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json; charset=utf-8',
|
||||||
|
'Content-Length': Buffer.byteLength(data, 'utf8')
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const req = https.request(options, (res) => {
|
||||||
|
console.log('OK');
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', (e) => {
|
||||||
|
console.error(`Error: ${e.message}`);
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
req.setTimeout(10000, () => {
|
||||||
|
console.log('Timeout');
|
||||||
|
process.exit(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
req.write(data, 'utf8');
|
||||||
|
req.end();
|
||||||
@@ -15,11 +15,15 @@ Write-Host "📋 Copying hook files..." -ForegroundColor Yellow
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
Copy-Item -Path "git-hooks\pre-commit" -Destination ".git\hooks\pre-commit" -Force
|
Copy-Item -Path "git-hooks\pre-commit" -Destination ".git\hooks\pre-commit" -Force
|
||||||
|
Copy-Item -Path "git-hooks\post-commit" -Destination ".git\hooks\post-commit" -Force
|
||||||
|
Copy-Item -Path "git-hooks\post-commit.bat" -Destination ".git\hooks\post-commit.bat" -Force
|
||||||
|
Copy-Item -Path "git-hooks\send-discord.js" -Destination ".git\hooks\send-discord.js" -Force
|
||||||
|
|
||||||
Write-Host "✅ Git hooks installed!" -ForegroundColor Green
|
Write-Host "✅ Git hooks installed!" -ForegroundColor Green
|
||||||
Write-Host ""
|
Write-Host ""
|
||||||
Write-Host "Installed hooks:" -ForegroundColor Cyan
|
Write-Host "Installed hooks:" -ForegroundColor Cyan
|
||||||
Write-Host " - pre-commit: XLSX 데이터 검증" -ForegroundColor White
|
Write-Host " - pre-commit: XLSX 데이터 검증" -ForegroundColor White
|
||||||
|
Write-Host " - post-commit: Discord 알림 전송" -ForegroundColor White
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host "❌ Hook 파일 복사 실패: $_" -ForegroundColor Red
|
Write-Host "❌ Hook 파일 복사 실패: $_" -ForegroundColor Red
|
||||||
|
|||||||
Reference in New Issue
Block a user