Skip to content

Commit

Permalink
ci: run sq analysis only when push to main
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelTshDev committed Apr 8, 2024
1 parent 0151744 commit b6be7a5
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 26 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Serverless Boilerplate

on:
push:
branches:
- main

jobs:
tests:
runs-on: ubuntu-latest
name: Build
strategy:
matrix:
node-version: [20]

steps:
- uses: actions/checkout@v4
- run: cp .env.dist .env
- run: npm ci
- run: npm run lint
- run: npm run test-coverage
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage/

sonarqube-analysis:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: coverage
path: coverage/
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
30 changes: 5 additions & 25 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Serverless Boilerplate

on: [push]
on:
push:
branches-ignore:
- main

jobs:
tests:
Expand All @@ -15,27 +18,4 @@ jobs:
- run: cp .env.dist .env
- run: npm ci
- run: npm run lint
- run: npm run test-coverage
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: coverage
path: coverage/

sonarqube-analysis:
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download artifact
uses: actions/download-artifact@v2
with:
name: coverage
path: coverage/
- name: SonarQube Scan
uses: sonarsource/sonarqube-scan-action@master
env:
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- run: npm run test
5 changes: 4 additions & 1 deletion bitbucket-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ definitions:
pipelines:
default:
- step: *compile
- step: *sonarqube-analysis

custom:
deploy-to-dev:
- step: *compile
Expand All @@ -43,6 +43,9 @@ pipelines:
name: Deploy to DEV

branches:
main:
- step: *compile
- step: *sonarqube-analysis
master:
- step: *compile
- step:
Expand Down

0 comments on commit b6be7a5

Please sign in to comment.