From 83f0b1039730fe065c737d04ec4d94035605cdfe Mon Sep 17 00:00:00 2001 From: gimnathperera Date: Fri, 29 Sep 2023 23:51:07 +0530 Subject: [PATCH] config: add CI/CD github workflows --- .github/workflows/main.yml | 37 ++++++++++++++++++++++++++++++ .github/workflows/pull-request.yml | 35 ++++++++++++++++++++++++++++ .husky/pre-commit | 3 ++- 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/main.yml create mode 100644 .github/workflows/pull-request.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..197a2e9 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: Main +on: + push: + branches: + - main + +jobs: + linter: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: ['18.x'] + + steps: + - name: Git checkout + uses: actions/checkout@v3 + + - name: Add SHORT_SHA env property with commit short sha + run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV + + - name: Git sort sha + run: echo ${SHORT_SHA} + + - name: Setup Node.js version ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install PNPM + run: npm install -g pnpm + + - name: Install dependencies using PNPM + run: pnpm install --frozen-lockfile + + - name: Linter + run: pnpm run lint diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml new file mode 100644 index 0000000..07897ca --- /dev/null +++ b/.github/workflows/pull-request.yml @@ -0,0 +1,35 @@ +name: Linter +on: + pull_request: + +jobs: + linter: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: ['18.x'] + + steps: + - name: Git checkout + uses: actions/checkout@v3 + + - name: Add SHORT_SHA env property with commit short sha + run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-8`" >> $GITHUB_ENV + + - name: Git sort sha + run: echo ${SHORT_SHA} + + - name: Setup Node.js version ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + + - name: Install PNPM + run: npm install -g pnpm + + - name: Install dependencies using PNPM + run: pnpm install --frozen-lockfile + + - name: Linter + run: pnpm run lint diff --git a/.husky/pre-commit b/.husky/pre-commit index 2b0c506..846d5a8 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -26,7 +26,8 @@ pnpm check-types || Please resolve the indicated problems before proceeding.' false; ) -# If all checks pass, proceed to build + + echo '👍 No linting or type issues found...'