Skip to content

Commit

Permalink
FORCE RESET HISTORY
Browse files Browse the repository at this point in the history
  • Loading branch information
1ilsang committed Aug 23, 2024
0 parents commit 2c417c8
Show file tree
Hide file tree
Showing 384 changed files with 37,785 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @1ilsang
93 changes: 93 additions & 0 deletions .github/actions/netlify-preview/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: netlify-preview

inputs:
NETLIFY_SITE_ID:
required: true
NETLIFY_API_TOKEN:
required: true
HEAD_COMMIT:
required: true

runs:
using: composite

steps:
# https://cli.netlify.com/
- name: Netlify deploy
id: netlify-deploy
shell: bash
run: |
pnpm nf deploy \
--dir out \
--site ${{ inputs.NETLIFY_SITE_ID }} \
--auth ${{ inputs.NETLIFY_API_TOKEN }} \
--json \
> deploy_output.json
- name: Generate URL Preview
id: url-preview
shell: bash
# pnpm 샌드박스 로그가 json 파일에 상단에 추가되는 버그가 있음.
# 로그 삭제후 5번째 라인부터 JSON 파일 재생성
run: |
tail -n +5 deploy_output.json > parsed_output.json
echo $(cat parsed_output.json)
NETLIFY_PREVIEW_URL=$(jq -r '.deploy_url' parsed_output.json)
echo "NETLIFY_PREVIEW_URL=$NETLIFY_PREVIEW_URL" >> "$GITHUB_OUTPUT"
- name: Comment URL Preview on PR
# https://octokit.github.io/rest.js/v20
uses: actions/github-script@v7
env:
NETLIFY_PREVIEW_URL: ${{ steps.url-preview.outputs.NETLIFY_PREVIEW_URL }}
HEAD_COMMIT: ${{ inputs.HEAD_COMMIT }}
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
async function getIssueNumber() {
const result = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner,
repo,
commit_sha: process.env.HEAD_COMMIT,
});
const issueNumber = result.data[0]?.number;
return issueNumber;
}
async function getExistPrevActionBot(issueNumber) {
const result = await github.rest.issues.listComments({
owner,
repo,
issue_number: issueNumber
});
const existPrevAction = result.data.find(comment => comment.user.login === 'github-actions[bot]');
return existPrevAction;
}
async function comment(){
const issueNumber = await getIssueNumber();
if (!issueNumber) {
console.log('No PR found for commit ' + process.env.HEAD_COMMIT);
return;
}
const prevActionBot = await getExistPrevActionBot(issueNumber);
const body = `Preview URL: ${process.env.NETLIFY_PREVIEW_URL}`;
if (prevActionBot?.id) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: prevActionBot.id,
body
});
} else {
await github.rest.issues.createComment({
owner,
repo,
issue_number: issueNumber,
body
});
}
}
comment();
32 changes: 32 additions & 0 deletions .github/actions/nextjs-build-export/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# https://docs.github.com/en/actions/creating-actions/creating-a-composite-action?platform=mac#creating-an-action-metadata-file
name: nextjs-build-export

inputs:
e2e:
required: false
default: 'false'

runs:
using: composite

steps:
- name: Restore Next.js related caches
uses: actions/cache@v4
with:
path: |
${{ github.workspace }}/.next
${{ github.workspace }}/out
key: ${{ runner.os }}-nextjs-store-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx', '**.md', '**.html', '**.png') }}-${{ inputs.e2e == 'true' && 'e2e' || 'default' }}
restore-keys: |
${{ runner.os }}-nextjs-store-${{ hashFiles('**/pnpm-lock.yaml') }}-
id: cache-nextjs-build

- name: Build and Export [default]
shell: bash
if: steps.cache-nextjs-build.outputs.cache-hit != 'true' && inputs.e2e == 'false'
run: pnpm build

- name: Build and Export [e2e]
shell: bash
if: steps.cache-nextjs-build.outputs.cache-hit != 'true' && inputs.e2e == 'true'
run: pnpm e2e:build
25 changes: 25 additions & 0 deletions .github/actions/playwright-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: playwright-install

runs:
using: composite

steps:
# https://github.com/microsoft/playwright/issues/7249#issuecomment-1373375487
- name: Get playwright version
shell: bash
run: |
echo "PLAYWRIGHT_VERSION=$(node -e "process.stdout.write(require('@playwright/test/package.json').version)")" >> $GITHUB_OUTPUT
id: playwright-version

- name: Cache Playwright Browsers for Playwright's Version
uses: actions/cache@v4
with:
# https://playwright.dev/docs/browsers#managing-browser-binaries
path: ~/Library/Caches/ms-playwright
key: ${{ runner.os }}-playwright-${{ steps.playwright-version.outputs.PLAYWRIGHT_VERSION }}
id: cache-playwright-browsers

- name: Setup Playwright
shell: bash
if: steps.cache-playwright-browsers.outputs.cache-hit != 'true'
run: pnpm e2e:install
32 changes: 32 additions & 0 deletions .github/actions/pnpm-install/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: pnpm-install

runs:
using: composite

steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc

- name: Install pnpm
uses: pnpm/action-setup@v3
with:
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
shell: bash
run: pnpm install
51 changes: 51 additions & 0 deletions .github/workflows/code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: code

on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
pull-requests: write

jobs:
lint:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: 🌱 Install pnpm
uses: ./.github/actions/pnpm-install

- name: 🏁 Lint
run: pnpm lint

build-export:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: 🌱 Install pnpm
uses: ./.github/actions/pnpm-install

- name: 🏗 Build and Export
uses: ./.github/actions/nextjs-build-export

preview:
runs-on: macos-latest
needs: build-export
steps:
- uses: actions/checkout@v4

# 캐싱 된 값을 사용
- name: 🌱 Install pnpm
uses: ./.github/actions/pnpm-install
- name: 🏗 Build and Export
uses: ./.github/actions/nextjs-build-export

- name: 🌈 Netlify preview
uses: ./.github/actions/netlify-preview
with:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_API_TOKEN: ${{ secrets.NETLIFY_API_TOKEN }}
HEAD_COMMIT: ${{ github.event.pull_request.head.sha }}
55 changes: 55 additions & 0 deletions .github/workflows/e2e-reusable.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
name: e2e-reusable

on:
workflow_call:
inputs:
others:
type: boolean
default: false
dom-snapshot:
type: boolean
default: false
screen-snapshot:
type: boolean
default: false

jobs:
i:
timeout-minutes: 60
runs-on: macos-latest
env:
TZ: Asia/Seoul

steps:
- uses: actions/checkout@v4

- name: 🌱 Install pnpm
uses: ./.github/actions/pnpm-install

- name: 🥦 Install playwright
uses: ./.github/actions/playwright-install

- name: 🏗 Build and Export
uses: ./.github/actions/nextjs-build-export
with:
e2e: 'true'

- name: 🍄 Run Playwright [others]
if: inputs.others
run: pnpm e2e:others

- name: 🧊 Run Playwright [dom-snapshot]
if: inputs.dom-snapshot
run: pnpm e2e:dom

- name: 🩸 Run Playwright [screen-snapshot]
if: inputs.screen-snapshot
run: pnpm e2e:screen

- uses: actions/upload-artifact@v4
if: failure()
with:
name: playwright-report-$${{ inputs.others && 'others' || inputs.dom-snapshot && 'dom-snapshot' || inputs.screen-snapshot && 'screen-snapshot' || 'no-input-name' }}
path: playwright-report/
retention-days: 10
23 changes: 23 additions & 0 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: e2e

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
others:
uses: './.github/workflows/e2e-reusable.yml'
with:
others: true

dom-snapshot:
uses: './.github/workflows/e2e-reusable.yml'
with:
dom-snapshot: true

screen-snapshot:
uses: './.github/workflows/e2e-reusable.yml'
with:
screen-snapshot: true
19 changes: 19 additions & 0 deletions .github/workflows/jest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: jest

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
jest:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4

- name: 🌱 Install pnpm
uses: ./.github/actions/pnpm-install

- name: 🪤 Jest
run: pnpm jest
36 changes: 36 additions & 0 deletions .github/workflows/label-mailto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: label-mailto

on:
issues:
types: [labeled]

jobs:
send_notification:
runs-on: ubuntu-latest

steps:
- name: Trim issue body to 3 lines
run: |
echo "${{ github.event.issue.body }}" | head -n 3 > trimmed_body.txt
echo "TRIMMED_BODY<<EOF" >> $GITHUB_ENV
while IFS= read -r line; do
echo "$line" >> $GITHUB_ENV
done < trimmed_body.txt
echo "EOF" >> $GITHUB_ENV
- name: Send Email Notification
uses: dawidd6/action-send-mail@v3
env:
TRIMMED_BODY: ${{ env.TRIMMED_BODY }}
with:
secure: true
server_address: smtp.gmail.com
server_port: 465
# user credentials
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
# Mail
subject: '[Issue] ${{ github.event.issue.title }}: ${{github.event.label.name}}'
body: "Issue URL: ${{ github.event.issue.html_url }}\n\nBody:\n${{env.TRIMMED_BODY}}"
to: [email protected]
from: 1ilsang.dev
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
node_modules
build
dist
out
.next/

.DS_Store

# TypeScript cache
*.tsbuildinfo

# Playwright
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/

# Jest
/coverage/
Loading

0 comments on commit 2c417c8

Please sign in to comment.