token-guardian
Version:
A comprehensive solution for protecting and managing API tokens and secrets
93 lines (71 loc) • 2 kB
YAML
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-and-test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check types
run: npx tsc --noEmit
- name: Run linting
run: npm run lint
- name: Build
run: npm run build
- name: Test with coverage
run: npm run coverage
# Add artifact upload for test coverage
- name: Archive code coverage results
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: coverage/
retention-days: 5
security-scan:
runs-on: ubuntu-latest
needs: build-and-test
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run npm audit
run: npm audit --audit-level=high
npm-test-publish:
runs-on: ubuntu-latest
needs: [build-and-test, security-scan]
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Test npm pack
run: |
npm pack
PACKAGE_NAME=$(npm pack | tail -n 1)
echo "Generated package: $PACKAGE_NAME"
tar -tzf $PACKAGE_NAME