[Snyk] Security upgrade langchain from 0.1.37 to 0.2.0 #26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Backend CI | |
| on: | |
| push: | |
| branches: [ main ] | |
| paths: | |
| - 'server/**' | |
| - '.github/workflows/backend-ci.yml' | |
| pull_request: | |
| branches: [ main ] | |
| paths: | |
| - 'server/**' | |
| - '.github/workflows/backend-ci.yml' | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository }}/sql-assistant-server | |
| jobs: | |
| check-changes: | |
| name: Check for Backend Changes | |
| runs-on: ubuntu-latest | |
| outputs: | |
| has_changes: ${{ steps.filter.outputs.server }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dorny/paths-filter@v3 | |
| id: filter | |
| with: | |
| filters: | | |
| server: | |
| - 'server/**' | |
| - '.github/workflows/backend-ci.yml' | |
| security-scan: | |
| name: Security Scan | |
| needs: check-changes | |
| if: ${{ needs.check-changes.outputs.has_changes == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: server/package-lock.json | |
| - name: Install dependencies | |
| working-directory: ./server | |
| run: npm install | |
| - name: Run Snyk security scan | |
| uses: snyk/actions/node@master | |
| env: | |
| SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
| test: | |
| name: Test and Lint | |
| needs: check-changes | |
| if: ${{ needs.check-changes.outputs.has_changes == 'true' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'npm' | |
| cache-dependency-path: server/package-lock.json | |
| - name: Install dependencies | |
| working-directory: ./server | |
| run: npm install | |
| - name: Run linting | |
| working-directory: ./server | |
| run: npm run lint | |
| - name: Run tests | |
| working-directory: ./server | |
| run: npm test | |
| build-and-push: | |
| name: Build and Push Docker Image | |
| needs: [check-changes, test] | |
| if: ${{ needs.check-changes.outputs.has_changes == 'true' }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Extract metadata for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
| tags: | | |
| type=sha,format=short | |
| type=ref,event=branch | |
| type=ref,event=tag | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: ./server | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |