-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
weekly dashboard 를 node-cron 에서 github action으로 마이그레이션
- Loading branch information
Showing
7 changed files
with
92 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: send-weekly-dashboard | ||
|
||
on: | ||
schedule: | ||
- cron: '20 2 * * 1' # 월요일 한국시간 오전 11시 20분 | ||
|
||
jobs: | ||
cron: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18.x] | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Setup Node.js environment | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
cache: 'yarn' | ||
|
||
# cron job을 실행합니다. | ||
- name: run script | ||
run: | | ||
yarn install | ||
SLACK_AUTH_TOKEN=${{ secrets.SLACK_AUTH_TOKEN }} \ | ||
SLACK_ACTIVE_CHANNEL_ID=${{ secrets.SLACK_ACTIVE_CHANNEL_ID }} \ | ||
SLACK_WATCHER_CHANNEL_ID=${{ secrets.SLACK_WATCHER_CHANNEL_ID }} \ | ||
GHP_ACCESS_TOKEN=${{ secrets.GHP_ACCESS_TOKEN }} \ | ||
yarn send:weekly-summary |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
FROM node:18.11.0-alpine | ||
FROM node:18.17.1-alpine | ||
ARG SLACK_BOT_TOKEN | ||
ARG SLACK_AUTH_TOKEN | ||
ARG SLACK_PUPURI_CHANNEL_ID | ||
ARG SLACK_ACTIVE_CHANNEL_ID | ||
ARG SLACK_WATCHER_CHANNEL_ID | ||
ARG GHP_ACCESS_TOKEN | ||
COPY . . | ||
RUN echo "SLACK_BOT_TOKEN=${SLACK_BOT_TOKEN}" >> .env.local | ||
RUN echo "SLACK_AUTH_TOKEN=${SLACK_AUTH_TOKEN}" >> .env.local | ||
RUN echo "SLACK_PUPURI_CHANNEL_ID=${SLACK_PUPURI_CHANNEL_ID}" >> .env.local | ||
RUN echo "SLACK_ACTIVE_CHANNEL_ID=${SLACK_ACTIVE_CHANNEL_ID}" >> .env.local | ||
RUN echo "SLACK_WATCHER_CHANNEL_ID=${SLACK_WATCHER_CHANNEL_ID}" >> .env.local | ||
RUN echo "GHP_ACCESS_TOKEN=${GHP_ACCESS_TOKEN}" >> .env.local | ||
RUN yarn install | ||
RUN yarn build | ||
CMD ["yarn", "start"] | ||
CMD ["yarn", "start:server"] | ||
|
||
EXPOSE 3000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,34 @@ | ||
{ | ||
"name": "pupuri-bot", | ||
"version": "0.0.1", | ||
"version": "1.0.0", | ||
"description": "wafflestudio pupuri bot", | ||
"main": "index.ts", | ||
"repository": "https://github.com/wafflestudio/pupuri-bot", | ||
"author": "woohm402 <[email protected]>", | ||
"license": "MIT", | ||
"private": false, | ||
"scripts": { | ||
"start": "node dist/src/index.js", | ||
"build": "tsc -p .", | ||
"dev": "nodemon --watch \"src/**/*.ts\" --exec \"ts-node\" src/index.ts", | ||
"deploy": "scripts/deploy.sh", | ||
"start:server": "ts-node src/server.ts", | ||
"send:weekly-dashboard": "ts-node src/weekly-dashboard.ts", | ||
"deploy-server": "scripts/deploy.sh", | ||
"test:unit": "jest", | ||
"lint": "eslint ./src" | ||
}, | ||
"dependencies": { | ||
"dotenv": "16.0.3", | ||
"express": "4.18.2", | ||
"node-cron": "3.0.2" | ||
"express": "4.18.2" | ||
}, | ||
"devDependencies": { | ||
"@jest/globals": "29.5.0", | ||
"@types/express": "4.17.17", | ||
"@types/node": "18.15.10", | ||
"@types/node-cron": "3.0.7", | ||
"@typescript-eslint/eslint-plugin": "5.57.0", | ||
"@typescript-eslint/parser": "5.57.0", | ||
"dotenv": "16.0.3", | ||
"eslint": "8.37.0", | ||
"eslint-config-prettier": "8.8.0", | ||
"eslint-plugin-prettier": "4.2.1", | ||
"eslint-plugin-simple-import-sort": "10.0.0", | ||
"jest": "29.5.0", | ||
"nodemon": "2.0.22", | ||
"prettier": "2.8.7", | ||
"ts-jest": "29.0.5", | ||
"ts-node": "10.9.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import dotenv from 'dotenv'; | ||
|
||
import { implementDashboardService } from './infrastructures/implementDashboardService'; | ||
import { implementGithubApiRepository } from './infrastructures/implementGithubApiRepository'; | ||
import { implementGithubHttpClient } from './infrastructures/implementGithubHttpClient'; | ||
import { implementSlackHttpClient } from './infrastructures/implementSlackHttpClient'; | ||
|
||
dotenv.config({ path: '.env.local' }); | ||
|
||
const slackAuthToken = process.env.SLACK_AUTH_TOKEN; | ||
const githubAccessToken = process.env.GHP_ACCESS_TOKEN; | ||
const slackWatcherChannelId = process.env.SLACK_WATCHER_CHANNEL_ID; | ||
const slackActiveChannelId = process.env.SLACK_ACTIVE_CHANNEL_ID; | ||
|
||
if (!slackAuthToken) throw new Error('Missing Slack Auth Token'); | ||
if (!githubAccessToken) throw new Error('Missing Github Access Token'); | ||
if (!slackWatcherChannelId) throw new Error('Missing Slack Watcher Channel ID'); | ||
if (!slackActiveChannelId) throw new Error('Missing Slack Active Channel ID'); | ||
|
||
/** | ||
██████╗ ███████╗██████╗ ███████╗███╗ ██╗██████╗ ███████╗███╗ ██╗ ██████╗██╗███████╗███████╗ | ||
██╔══██╗██╔════╝██╔══██╗██╔════╝████╗ ██║██╔══██╗██╔════╝████╗ ██║██╔════╝██║██╔════╝██╔════╝ | ||
██║ ██║█████╗ ██████╔╝█████╗ ██╔██╗ ██║██║ ██║█████╗ ██╔██╗ ██║██║ ██║█████╗ ███████╗ | ||
██║ ██║██╔══╝ ██╔═══╝ ██╔══╝ ██║╚██╗██║██║ ██║██╔══╝ ██║╚██╗██║██║ ██║██╔══╝ ╚════██║ | ||
██████╔╝███████╗██║ ███████╗██║ ╚████║██████╔╝███████╗██║ ╚████║╚██████╗██║███████╗███████║ | ||
╚═════╝ ╚══════╝╚═╝ ╚══════╝╚═╝ ╚═══╝╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝╚═╝╚══════╝╚══════╝ | ||
*/ | ||
const slackClient = implementSlackHttpClient({ | ||
external: { slackAuthToken }, | ||
channelIds: { | ||
'slack-watcher': slackWatcherChannelId, | ||
active: slackActiveChannelId, | ||
}, | ||
}); | ||
const githubClient = implementGithubHttpClient({ githubAccessToken }); | ||
const githubApiRepository = implementGithubApiRepository({ githubClient }); | ||
const dashboardService = implementDashboardService({ githubApiRepository, slackClient }); | ||
|
||
dashboardService.sendGithubTopRepositoriesLastWeek('wafflestudio'); |
Oops, something went wrong.