diff --git a/.github/workflows/ci-publish.yaml b/.github/workflows/ci-publish.yaml new file mode 100644 index 00000000..39f2b766 --- /dev/null +++ b/.github/workflows/ci-publish.yaml @@ -0,0 +1,63 @@ +name: CI workflow to publish to npm + +on: + pull_request: + # PR is targeting main branch + branches: + - main + # Triggered only when package.json is modified + paths: + - 'package.json' + # Triggered only the PR is merged + types: [closed] + +jobs: + # Add timestamp + timestamp: + runs-on: ubuntu-latest + # Trigger the workflow only if the PR is from dev branch + if: github.event.pull_request.head.repo.full_name == 'dev' + steps: + - name: Generate timestamp + run: | + echo "TIMESTAMP=$(TZ='America/Los_Angeles' date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV + + - name: Print timestamp + run: | + echo "Execution time (Pacific Time Zone): $TIMESTAMP" + + build-test-publish: + runs-on: ubuntu-latest + # Trigger the workflow only if the PR is from dev branch + if: github.event.pull_request.head.repo.full_name == 'dev' + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + + - uses: pnpm/action-setup@d882d12c64e032187b2edb46d3a0d003b7a43598 # v2.4.0 + with: + version: 8.8.0 + + - name: Setup Node.js environment + uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1 + with: + node-version: 20.0.0 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Build + run: pnpm build + + - name: Test + run: pnpm test + + # - name: Publish to npm + # run: | + # echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > ~/.npmrc + # npm publish + # env: + # NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + # \ No newline at end of file