From 0ceaa9122b0ea298c041d7be1659d41a581cf609 Mon Sep 17 00:00:00 2001 From: woorim960 Date: Sun, 2 Oct 2022 03:00:00 +0900 Subject: [PATCH] ci: add ci & release actions files #166 --- .github/workflows/ci.yml | 76 ++++++++++++++++++++++++++++ .github/workflows/release-to-npm.yml | 47 +++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 .github/workflows/release-to-npm.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e69de29..50b57fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -0,0 +1,76 @@ +# ./github/workflows/ci.yml +# Excute lint and build. + +name: CI + +on: + push: + branches: + - develop + pull_request: + branches: + - develop + +env: + NODE_VERSION: 16.x + +jobs: + install: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NODE_VERSION }} + - uses: actions/cache@v2 + id: node-cache + with: + path: '**/node_modules' + key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Install dependencies + if: steps.node-cache.outputs.cache-hit != 'true' + run: npm ci --ignore-scripts + + lint: + runs-on: ubuntu-latest + needs: [install, release] + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Run linters + uses: wearerequired/lint-action@v1 + with: + git_email: 'woorimprog@gmail.com' + auto_fix: true + commit_message: 'style: fix code style issues with ${linter}' + eslint: true + eslint_extensions: 'js,jsx,ts,tsx' + prettier: true + prettier_extensions: 'js,jsx,ts,tsx,css,html,scss' + + build: + runs-on: ubuntu-latest + needs: [install] + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Build + run: npm run build + + # test: + # runs-on: ubuntu-latest + # needs: [install] + # steps: + # - uses: actions/checkout@v2 + # - uses: actions/cache@v2 + # with: + # path: "**/node_modules" + # key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/package-lock.json') }} + # - name: Test + # run: npm test diff --git a/.github/workflows/release-to-npm.yml b/.github/workflows/release-to-npm.yml new file mode 100644 index 0000000..e1a9bf5 --- /dev/null +++ b/.github/workflows/release-to-npm.yml @@ -0,0 +1,47 @@ +# ./github/workflows/release-to-npm.yml +# Excute release to npm. + +name: Release to NPM + +on: + push: + branches: + - master + pull_request: + branches: + - master + +env: + NODE_VERSION: 16.x + +jobs: + install: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 + with: + node-version: ${{ env.NODE_VERSION }} + - uses: actions/cache@v2 + id: node-cache + with: + path: '**/node_modules' + key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Install dependencies + if: steps.node-cache.outputs.cache-hit != 'true' + run: npm ci --ignore-scripts + + release: + runs-on: ubuntu-latest + needs: [install] + steps: + - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-${{ env.NODE_VERSION }}-modules-${{ hashFiles('**/package-lock.json') }} + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + run: npx semantic-release