Skip to content

Commit abbc527

Browse files
committed
add: 公式ラインの通知をdiscordに転送する
1 parent f9c0d96 commit abbc527

File tree

7 files changed

+116
-0
lines changed

7 files changed

+116
-0
lines changed
+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Build & Deploy Uplim Kun Monitoring
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
paths:
8+
- packages/triplate-line/**
9+
workflow_dispatch:
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-22.04
14+
timeout-minutes: 15
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js 20.11.0
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20.11.0'
23+
24+
- name: Install Packages
25+
run: |
26+
corepack enable
27+
yarn workspaces focus triplate-line
28+
29+
- name: Create .clasprc.json
30+
run: |
31+
echo "${{ secrets.UPLIM_INFO_BASE64 }}" | base64 --decode > ~/.clasprc.json
32+
33+
- name: Create .clasp.json
34+
run: |
35+
cat > ./packages/triplate-line/.clasp.json <<EOF
36+
{
37+
"scriptId": "${{ secrets.TRIPLATE_LINE_SCRIPT_ID }}",
38+
"rootDir": "./dist"
39+
}
40+
EOF
41+
42+
- name: Build & Deploy
43+
run: |
44+
yarn workspace triplate-line push

.yarn/install-state.gz

585 Bytes
Binary file not shown.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"timeZone": "Asia/Tokyo",
3+
"dependencies": {},
4+
"exceptionLogging": "STACKDRIVER",
5+
"runtimeVersion": "V8",
6+
"oauthScopes": ["https://www.googleapis.com/auth/script.external_request"]
7+
}

packages/triplate-line/build.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
const { GasPlugin } = require("esbuild-gas-plugin");
2+
3+
require("esbuild")
4+
.build({
5+
entryPoints: ["src/main.ts"],
6+
bundle: true,
7+
outfile: "dist/main.js",
8+
plugins: [GasPlugin],
9+
})
10+
.catch(() => process.exit(1));

packages/triplate-line/package.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "triplate-line",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"build": "node build.js && cp appsscript.json dist/",
6+
"push": "yarn build && clasp push"
7+
},
8+
"devDependencies": {
9+
"@google/clasp": "2.4.2",
10+
"@types/google-apps-script": "1.0.77",
11+
"esbuild": "0.19.6",
12+
"esbuild-gas-plugin": "0.8.0"
13+
},
14+
"dependencies": {
15+
"utils": "workspace:*"
16+
}
17+
}

packages/triplate-line/src/main.ts

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { postMessage } from "utils";
2+
3+
function doPost(e: GoogleAppsScript.Events.DoPost) {
4+
const postData = JSON.parse(e.postData.contents).events[0];
5+
const lineMessageText = postData.message.text;
6+
7+
postMessage({
8+
username: "LINE Bot",
9+
parse: "full",
10+
avatar_url:
11+
"https://cdn.discordapp.com/attachments/792765244040675389/921661726863282176/pngegg.png",
12+
content: JSON.stringify(lineMessageText),
13+
});
14+
15+
return ContentService.createTextOutput(
16+
JSON.stringify({
17+
message: "Message received",
18+
}),
19+
).setMimeType(ContentService.MimeType.JSON);
20+
}
21+
22+
declare const global: Record<
23+
string,
24+
(e: GoogleAppsScript.Events.DoPost) => void
25+
>;
26+
global.doPost = doPost;

yarn.lock

+12
Original file line numberDiff line numberDiff line change
@@ -3724,6 +3724,18 @@ __metadata:
37243724
languageName: unknown
37253725
linkType: soft
37263726

3727+
"triplate-line@workspace:packages/triplate-line":
3728+
version: 0.0.0-use.local
3729+
resolution: "triplate-line@workspace:packages/triplate-line"
3730+
dependencies:
3731+
"@google/clasp": "npm:2.4.2"
3732+
"@types/google-apps-script": "npm:1.0.77"
3733+
esbuild: "npm:0.19.6"
3734+
esbuild-gas-plugin: "npm:0.8.0"
3735+
utils: "workspace:*"
3736+
languageName: unknown
3737+
linkType: soft
3738+
37273739
"ts2gas@npm:^4.2.0":
37283740
version: 4.2.0
37293741
resolution: "ts2gas@npm:4.2.0"

0 commit comments

Comments
 (0)