From e82cc1b45c71ce28b0967c37ede1632b269a4910 Mon Sep 17 00:00:00 2001 From: Rajesh Susai Date: Tue, 29 Oct 2024 11:41:45 -0400 Subject: [PATCH] fix github actions --- .github/workflows/main.yaml | 89 ++++++++++++++++++++++++++++++++++--- 1 file changed, 84 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d67daab..7e05f4b 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,6 +1,85 @@ -name: CI Pipeline -on: [push] +name: NPM Pipeline + +on: + workflow_call: {} + push: + branches: + - "*" + tags: + - "v*" + jobs: - legion-npm-pipeline: - uses: meltwater/legion-github-repos/.github/workflows/legion-npm-package.yml@master - secrets: inherit \ No newline at end of file + Test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: "npm" + registry-url: https://registry.npmjs.org + cache-dependency-path: package-lock.json + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_INSTALL_TOKEN }} + + - name: Install dependencies + run: npm ci + + - name: Run tests + run: npm test + + Build: + runs-on: ubuntu-latest + needs: Test + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: "npm" + registry-url: https://registry.npmjs.org + cache-dependency-path: package-lock.json + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_INSTALL_TOKEN }} + + - name: Install dependencies + run: npm ci + + - name: Build package + run: npm run build + + Publish: + runs-on: ubuntu-latest + needs: Build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version-file: '.nvmrc' + cache: "npm" + registry-url: https://registry.npmjs.org + cache-dependency-path: package-lock.json + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} + + - name: Install dependencies + run: npm ci + + - name: Build package + run: npm run build + + - name: Publish package + run: npm publish \ No newline at end of file