Skip to content

ci: ci lint check 파이프라인 적용 (#97) #2

ci: ci lint check 파이프라인 적용 (#97)

ci: ci lint check 파이프라인 적용 (#97) #2

Workflow file for this run

name: CI
on:
pull_request:
branches: [develop]
push:
branches: [develop]
env:
CACHED_DEPENDENCY_PATHS: |
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
CACHED_BUILD_PATHS: ${{ github.workspace }}/.next
DEFAULT_NODE_VERSION: "v20.12.2"
DEFAULT_YARN_VERSION: "4.5.0"
jobs:
job_install_dependencies:
name: Install Dependencies
runs-on: ubuntu-latest
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Set up Yarn
run: |
corepack enable
yarn set version ${{ env.DEFAULT_YARN_VERSION }}
yarn --version
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
- name: Compute dependency cache key
id: compute_lockfile_hash
run: echo "hash=${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}" >> $GITHUB_OUTPUT
- name: Check dependency cache
uses: actions/cache@v4
id: cache_dependencies
with:
path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
${{ env.CACHED_DEPENDENCY_PATHS }}
key: ${{ steps.compute_lockfile_hash.outputs.hash }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install dependencies
if: steps.cache_dependencies.outputs.cache-hit != 'true'
run: yarn install --immutable
outputs:
dependency_cache_key: ${{ steps.compute_lockfile_hash.outputs.hash }}
yarn_cache_dir_path: |
${{ steps.yarn-cache-dir-path.outputs.dir }}
${{ env.CACHED_DEPENDENCY_PATHS }}
continuous-integration:
name: check lint
needs: [job_install_dependencies]
runs-on: ubuntu-latest
steps:
- name: Check out current commit (${{ github.sha }})
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.DEFAULT_NODE_VERSION }}
- name: Check dependency cache
uses: actions/cache@v4
with:
path: ${{ needs.job_install_dependencies.outputs.yarn_cache_dir_path }}
key: ${{ needs.job_install_dependencies.outputs.dependency_cache_key }}
- name: Check Lint
if: ${{ github.event_name == 'pull_request' }}
run: yarn run eslint $(git diff --name-only --diff-filter=d origin/main | grep -E '(.js$|.jsx|.ts$|.tsx$)')