Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ jobs:
- name: Build TypeScript
run: npm run build

- name: Verify build output
run: |
echo "📁 dist フォルダの内容:"
ls -la dist/
echo ""
echo "📄 appsscript.json の内容:"
cat dist/appsscript.json
echo ""
echo "📊 main.js のサイズ:"
wc -c dist/main.js
- name: Setup clasp credentials
env:
CLASPRC_JSON: ${{ secrets.CLASPRC_JSON }}
Expand Down
7 changes: 5 additions & 2 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import esbuild from 'esbuild';
import { GasPlugin } from 'esbuild-gas-plugin';
import { copyFileSync, mkdirSync } from 'fs';

// distフォルダを作成(存在しない場合)
Expand All @@ -14,7 +13,11 @@ esbuild
bundle: true,
minify: true,
outfile: './dist/main.js',
plugins: [GasPlugin],
format: 'iife',
globalName: '__bundle__',
footer: {
js: 'function onEdit(e){__bundle__.onEdit(e)}',
},
})
.then(() => {
console.log('✅ Build succeeded!');
Expand Down
63 changes: 0 additions & 63 deletions src/App.ts

This file was deleted.

40 changes: 31 additions & 9 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,33 @@
import { onEdit, testNotification } from './App';
import { getApplicationFromRow } from './application';
import { sendDiscordNotification } from './discord';

interface Global {
onEdit: typeof onEdit;
testNotification: typeof testNotification;
}
declare const global: Global;
/**
* スプレッドシートに行が追加されたときのトリガー
*/
export function onEdit(e: GoogleAppsScript.Events.SheetsOnEdit) {
try {
const range = e.range;
const sheet = range.getSheet();
const row = range.getRow();

// ヘッダー行(1行目)は無視
if (row <= 1) {
return;
}

// 申請情報を取得
const application = getApplicationFromRow(sheet, row);

// entryPoints
global.onEdit = onEdit;
global.testNotification = testNotification;
if (!application) {
Logger.log(`行${row}: 申請情報が不完全のため通知をスキップ`);
return;
}

// Discord通知を送信
sendDiscordNotification(application);
Logger.log(`行${row}: 通知送信完了`);
} catch (error) {
Logger.log(`エラー: ${error}`);
throw error;
}
}