name: Continuous Integration
on:
  pull_request:
    branches: [ main ]
jobs:
  deploy:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [ 18.x ]
    steps:
      - uses: actions/checkout@v3

      - name: Setup Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@v3
        with:
          always-auth: true
          node-version: ${{ matrix.node-version }}
          registry-url: https://registry.npmjs.org/

      - name: Install Dependencies
        run: npm ci

      - name: Run Unit Tests
        run: npm run test
        env:
          API_STACKS: ${{ secrets.API_STACKS }}

      - name: Version Bump
        run: | 
          npm run version:bump
          git config --local user.email "mihnea.dev@gmail.com"
          git config --local user.name "Mihnea Manolache"
          git fetch
          git checkout origin/$GITHUB_HEAD_REF
          git add .
          git commit -m "CI: Version bump"
          git push origin HEAD:$GITHUB_HEAD_REF