diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index 79e6036..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,46 +0,0 @@ -version: 2.1 - -orbs: - prodsec: snyk/prodsec-orb@1 - -jobs: - test_and_build: - working_directory: ~/app - docker: - - image: cimg/node:22.12.0 - steps: - - checkout - - setup_remote_docker: - docker_layer_caching: true - - run: - name: Install dependencies - command: npm install - - run: - name: Lint - command: npm run lint - - run: - name: Format - command: npm run format - - run: - name: Build with ts - command: npm run build - - run: - name: Run tests - command: npm run test - - run: - name: Build Docker image - command: | - TAG=0.1.$CIRCLE_BUILD_NUM - docker build -t code-review-exercise-node:$TAG . - -workflows: - version: 2 - CICD: - jobs: - - prodsec/secrets-scan: - name: Scan repository for secrets - context: - - snyk-bot-slack - channel: alerts-app-sec - trusted-branch: main - - test_and_build diff --git a/.github/actions/npminstall/action.yaml b/.github/actions/npminstall/action.yaml new file mode 100644 index 0000000..eb16521 --- /dev/null +++ b/.github/actions/npminstall/action.yaml @@ -0,0 +1,18 @@ +name: "Install node and dependencies" +description: "Installs node and dependencies with npm ci" +inputs: + NODE_VERSION_FILE: + description: "Location of the .nvmrc file" + required: true +runs: + using: composite + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Node + uses: actions/setup-node@v4 + with: + node-version-file: ${{ inputs.NODE_VERSION_FILE }} + - name: Install + shell: bash + run: npm ci diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml new file mode 100644 index 0000000..50219b7 --- /dev/null +++ b/.github/workflows/cicd.yaml @@ -0,0 +1,67 @@ +--- +name: CICD +on: + pull_request: + branches: [main] + push: + branches: [main] +env: + NODE_VERSION_FILE: ".nvmrc" +jobs: + build-lint-format: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Node and dependencies + uses: ./.github/actions/npminstall + with: + node-version-file: ${{ env.NODE_VERSION_FILE }} + - name: Build with ts + run: npm run build + - name: Lint + run: npm run lint + - name: Format + run: npm run format + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build image + run: docker build -t code-review-exercise-node:${{ github.sha }} . + gitleaks: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Run Gitleaks + uses: gitleaks/gitleaks-action@v2 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE }} + snyk: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/node@0.4.0 + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + command: monitor + test: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Install Node and dependencies + uses: ./.github/actions/npminstall + with: + node-version-file: ${{ env.NODE_VERSION_FILE }} + - name: Test + run: npm run test