-
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.
- Loading branch information
Showing
5 changed files
with
195 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
.github/workflows/toyproject-21.5-three-days-dashboard.yml
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: toyproject-21.5-send-three-days-dashboard | ||
|
||
on: | ||
schedule: | ||
- cron: '20 2 * * *' # 한국 시간대, 매일 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_WEEKLY_CHANNEL_ID=C06BH14TZK6 \ | ||
SLACK_AUTH_TOKEN=${{ secrets.SLACK_AUTH_TOKEN }} \ | ||
GHP_ACCESS_TOKEN=${{ secrets.GHP_ACCESS_TOKEN }} \ | ||
GITHUB_ORGANIZATION=wafflestudio21-5 \ | ||
yarn send:toyproject-21.5-three-days-dashboard |
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
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,3 +1,4 @@ | ||
export type DashboardService = { | ||
sendGithubTopRepositoriesLastWeek: (organization: string) => Promise<void>; | ||
sendGithubTopRepositoriesPerTeamLastThreeDays: (organization: string) => Promise<void>; | ||
}; |
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,36 @@ | ||
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 slackWeeklyChannelId = process.env.SLACK_WEEKLY_CHANNEL_ID; | ||
const githubOrganization = process.env.GITHUB_ORGANIZATION; | ||
|
||
if (!slackAuthToken) throw new Error('Missing Slack Auth Token'); | ||
if (!githubAccessToken) throw new Error('Missing Github Access Token'); | ||
if (!slackWeeklyChannelId) throw new Error('Missing Slack Weekly Channel ID'); | ||
if (!githubOrganization) throw new Error('Missing Github Organization'); | ||
|
||
/** | ||
██████╗ ███████╗██████╗ ███████╗███╗ ██╗██████╗ ███████╗███╗ ██╗ ██████╗██╗███████╗███████╗ | ||
██╔══██╗██╔════╝██╔══██╗██╔════╝████╗ ██║██╔══██╗██╔════╝████╗ ██║██╔════╝██║██╔════╝██╔════╝ | ||
██║ ██║█████╗ ██████╔╝█████╗ ██╔██╗ ██║██║ ██║█████╗ ██╔██╗ ██║██║ ██║█████╗ ███████╗ | ||
██║ ██║██╔══╝ ██╔═══╝ ██╔══╝ ██║╚██╗██║██║ ██║██╔══╝ ██║╚██╗██║██║ ██║██╔══╝ ╚════██║ | ||
██████╔╝███████╗██║ ███████╗██║ ╚████║██████╔╝███████╗██║ ╚████║╚██████╗██║███████╗███████║ | ||
╚═════╝ ╚══════╝╚═╝ ╚══════╝╚═╝ ╚═══╝╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝╚═╝╚══════╝╚══════╝ | ||
*/ | ||
const slackClient = implementSlackHttpClient({ | ||
external: { slackAuthToken }, | ||
channelId: slackWeeklyChannelId, | ||
}); | ||
const githubClient = implementGithubHttpClient({ githubAccessToken }); | ||
const githubApiRepository = implementGithubApiRepository({ githubClient }); | ||
const dashboardService = implementDashboardService({ githubApiRepository, slackClient }); | ||
|
||
dashboardService.sendGithubTopRepositoriesPerTeamLastThreeDays(githubOrganization).catch(console.error); |