Skip to content

Commit 8b602e4

Browse files
committed
Initial commit
0 parents  commit 8b602e4

File tree

99 files changed

+24528
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+24528
-0
lines changed

.eslintrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
extends: ["@classmethod"],
3+
parserOptions: {
4+
project: true,
5+
tsconfigRootDir: __dirname,
6+
sourceType: "module",
7+
ecmaVersion: 2015,
8+
},
9+
ignorePatterns: ["**/*.js"],
10+
parser: "@typescript-eslint/parser",
11+
};

.github/dependabot.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: npm
4+
directory: /
5+
schedule:
6+
# MEMO: daily だとアクティブに開発をしていない期間に PR の作成頻度が過剰となるため、weekly を指定。
7+
interval: weekly
8+
groups:
9+
minor-and-patch:
10+
patterns:
11+
- "*"
12+
update-types:
13+
- minor
14+
- patch
15+
## 最新版にバグが含まれるなどアップデートさせたくないパッケージは ignore で指定
16+
# ignore:
17+
# - dependency-name: "dependency-name"

.github/pull_request_template.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## 機能概要
2+
3+
〇〇システムにおいて認証機能を実現する為に〇〇を実装します。
4+
5+
## 変更点
6+
7+
- [ ] 変更点 A
8+
- [ ] 変更点 B
9+
10+
## 対象外
11+
12+
- 対象外 A
13+
- 対象外 B
14+
15+
## アウトプット
16+
17+
(ScreenShot or JSON image)
18+
19+
## 手動テスト内容
20+
21+
- 単体テストがパスすることを確認
22+
- E2E テストがパスすることを確認
23+
24+
## 影響範囲
25+
26+
- 新規機能開発の為影響無し
27+
28+
## 関連課題
29+
30+
- 関連課題 URL
31+
32+
## その他
33+
34+
- 特記事項を記載
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# @see https://peno022.hatenablog.com/entry/add-issues-to-github-project
2+
name: Add issue to project
3+
4+
on:
5+
issues:
6+
types:
7+
- opened
8+
9+
jobs:
10+
add-to-project:
11+
name: Add issue to project
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/add-to-project@v0.5.0
15+
with:
16+
project-url: https://github.com/orgs/cm-cxlabs/projects/2
17+
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}

.github/workflows/cicd.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: CI/CD
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- synchronize
8+
- reopened
9+
- closed
10+
11+
env:
12+
TARGET_ENV: ${{ github.base_ref == 'main' && 'prd' || github.base_ref == 'staging' && 'stg' || 'dev' }}
13+
DEV_AWS_ACCOUNT_ID: ${{ vars.DEV_AWS_ACCOUNT_ID }}
14+
STG_AWS_ACCOUNT_ID: ${{ vars.STG_AWS_ACCOUNT_ID }}
15+
PRD_AWS_ACCOUNT_ID: ${{ vars.PRD_AWS_ACCOUNT_ID }}
16+
17+
jobs:
18+
Integration:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 10
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
25+
- name: Setup Node.js 20
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
cache: npm
30+
31+
- name: Cache Dependency
32+
uses: actions/cache@v4
33+
id: cache_dependency
34+
env:
35+
cache-name: cache-dependency
36+
with:
37+
path: "**/node_modules"
38+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
39+
40+
- name: Install Dependency
41+
if: ${{ steps.cache_dependency.outputs.cache-hit != 'true' }}
42+
run: npm ci --no-audit --progress=false --silent
43+
44+
- name: Check Format
45+
run: |
46+
npm run check:format
47+
48+
- name: Check Lint
49+
run: |
50+
npm run check:lint
51+
52+
- name: Check Type
53+
run: npm run check:type
54+
55+
- name: Check Cspell
56+
run: npm run check:cspell
57+
58+
- name: Cdk Snapshot Test
59+
run: npm run test-snapshot -- run
60+
61+
- name: Unit Test
62+
run: npm run test-unit -- run
63+
64+
# TODO: CD を Environments を使った実装に置き換え予定
65+
# @see https://github.com/classmethod-internal/icasu-cdk-serverless-api-sample/issues/342
66+
67+
Deploy:
68+
runs-on: ubuntu-latest
69+
timeout-minutes: 30
70+
if: github.event.pull_request.merged == true
71+
needs: Integration
72+
permissions:
73+
id-token: write
74+
contents: read
75+
steps:
76+
- name: Checkout
77+
uses: actions/checkout@v4
78+
79+
- name: Setup Node.js 20
80+
uses: actions/setup-node@v4
81+
with:
82+
node-version: 20
83+
cache: npm
84+
85+
- name: Restore Cache Dependency
86+
uses: actions/cache/restore@v4
87+
id: cache_dependency
88+
env:
89+
cache-name: cache-dependency
90+
with:
91+
path: "**/node_modules"
92+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
93+
94+
- name: Assume Role
95+
uses: aws-actions/configure-aws-credentials@v4
96+
with:
97+
aws-region: "ap-northeast-1"
98+
role-to-assume: ${{ env.TARGET_ENV == 'prd' && vars.PRD_AWS_OIDC_ROLE_ARN || env.TARGET_ENV == 'stg' && vars.STG_AWS_OIDC_ROLE_ARN || vars.DEV_AWS_OIDC_ROLE_ARN }}
99+
100+
- name: Deploy
101+
run: |
102+
npm run deploy:${{ env.TARGET_ENV }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# @see https://docs.github.com/ja/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
2+
name: Dependabot auto-merge
3+
# ブランチ保護が無効の場合は CI Fail 時も自動マージが行われてしまう。
4+
# TODO: ブランチ保護有効後にトリガーを pull_request に戻す。
5+
# on: pull_request
6+
on: workflow_dispatch
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
dependabot:
14+
runs-on: ubuntu-latest
15+
if: ${{ github.actor == 'dependabot[bot]' }}
16+
steps:
17+
- name: Dependabot metadata
18+
id: metadata
19+
uses: dependabot/fetch-metadata@v1
20+
with:
21+
github-token: "${{ secrets.GITHUB_TOKEN }}"
22+
- name: Enable auto-merge for Dependabot PRs
23+
# minor または patch バージョンのアップデートのみ自動マージ対象とする
24+
if: ${{steps.metadata.outputs.update-type != 'version-update:semver-major'}}
25+
run: gh pr merge --auto --merge "$PR_URL"
26+
env:
27+
# PR_URL: ${{github.event.pull_request.html_url}} # バリデーションエラー抑制のためコメントアウト。ブランチ保護有効後にコメントインする。
28+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# 指定のブランチを開発環境に手動デプロイするワークフロー
2+
#
3+
# TODO:
4+
# - Reusable workflow を使用して cicd.yml と処理を共通化する
5+
# @see https://docs.github.com/en/actions/using-workflows/reusing-workflows
6+
7+
name: Manual Deploy to Development
8+
9+
on:
10+
workflow_dispatch:
11+
inputs:
12+
branch:
13+
description: "Branch name"
14+
required: true
15+
default: develop
16+
17+
jobs:
18+
Deploy:
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 30
21+
permissions:
22+
id-token: write
23+
contents: read
24+
env:
25+
TARGET_ENV: dev
26+
DEV_AWS_ACCOUNT_ID: ${{ vars.DEV_AWS_ACCOUNT_ID }}
27+
steps:
28+
- name: Checkout
29+
uses: actions/checkout@v4
30+
with:
31+
ref: ${{ github.event.inputs.branch }}
32+
33+
- name: Setup Node.js 20
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
37+
cache: npm
38+
39+
- name: Cache Dependency
40+
uses: actions/cache@v4
41+
id: cache_dependency
42+
env:
43+
cache-name: cache-dependency
44+
with:
45+
path: "**/node_modules"
46+
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('package-lock.json') }}
47+
48+
- name: Assume Role
49+
uses: aws-actions/configure-aws-credentials@v4
50+
with:
51+
aws-region: "ap-northeast-1"
52+
role-to-assume: ${{ vars.DEV_AWS_OIDC_ROLE_ARN }}
53+
54+
- name: Deploy
55+
run: |
56+
npm run deploy:${{ env.TARGET_ENV }}
57+
58+
# TODO: E2E テスト実行処理の追加

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
.DS_Store
3+
.eslintcache
4+
tsconfig.tsbuildinfo
5+
.cspellcache

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

.vscode/extensions.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"recommendations": [
3+
"dbaeumer.vscode-eslint",
4+
"esbenp.prettier-vscode",
5+
"redhat.vscode-yaml",
6+
"Arjun.swagger-viewer"
7+
]
8+
}

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"[typescript]": {
3+
"editor.defaultFormatter": "esbenp.prettier-vscode"
4+
},
5+
"[javascript]": {
6+
"editor.defaultFormatter": "esbenp.prettier-vscode"
7+
},
8+
"editor.formatOnSave": true
9+
}

0 commit comments

Comments
 (0)