|
| 1 | +name: Build |
| 2 | + |
| 3 | +on: [push] |
| 4 | + |
| 5 | +jobs: |
| 6 | + |
| 7 | + # -- TESTS ------------------------------------------------------------------ |
| 8 | + tests: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + |
| 11 | + strategy: |
| 12 | + matrix: |
| 13 | + node-version: [12.x] |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v2 |
| 18 | + |
| 19 | + - name: Use Node.js ${{ matrix.node-version }} |
| 20 | + uses: actions/setup-node@v1 |
| 21 | + with: |
| 22 | + node-version: ${{ matrix.node-version }} |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: npm install |
| 26 | + |
| 27 | + - name: Run Unit-Tests + Code Coverage |
| 28 | + run: npm run test:coverage |
| 29 | + |
| 30 | + - name: Save Code Coverage |
| 31 | + uses: actions/upload-artifact@v2 |
| 32 | + with: |
| 33 | + name: code-coverage |
| 34 | + path: coverage |
| 35 | + |
| 36 | + sonarcloud: |
| 37 | + runs-on: ubuntu-latest |
| 38 | + needs: tests |
| 39 | + |
| 40 | + steps: |
| 41 | + - name: Checkout |
| 42 | + uses: actions/checkout@v2 |
| 43 | + |
| 44 | + - name: Download Code Coverage |
| 45 | + uses: actions/download-artifact@v2 |
| 46 | + with: |
| 47 | + name: code-coverage |
| 48 | + path: coverage |
| 49 | + |
| 50 | + - name: Get App Version |
| 51 | + run: ./scripts/version.sh |
| 52 | + |
| 53 | + - name: SonarCloud Scan |
| 54 | + uses: sonarsource/sonarcloud-github-action@master |
| 55 | + env: |
| 56 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} |
| 58 | + |
| 59 | + # functional-tests: |
| 60 | + # runs-on: ubuntu-latest |
| 61 | + # needs: tests |
| 62 | + |
| 63 | + # steps: |
| 64 | + # - name: Checkout |
| 65 | + # uses: actions/checkout@v2 |
| 66 | + |
| 67 | + # - name: Build docker image |
| 68 | + # run: docker build -t timoa/nodejs-encryption-api-example . |
| 69 | + |
| 70 | + # - name: Start Docker container |
| 71 | + # run: docker-compose up -d |
| 72 | + |
| 73 | + # - name: Check Docker container status |
| 74 | + # run: docker ps -a |
| 75 | + |
| 76 | + # - name: Install dependencies |
| 77 | + # run: npm install |
| 78 | + |
| 79 | + # - name: Run Functional tests |
| 80 | + # run: npm run test:functional |
| 81 | + |
| 82 | + # - name: Stop Docker container |
| 83 | + # run: docker-compose down |
| 84 | + |
| 85 | + # -- BUILD ------------------------------------------------------------------ |
| 86 | + build: |
| 87 | + runs-on: ubuntu-latest |
| 88 | + needs: tests |
| 89 | + if: github.ref == 'refs/heads/master' |
| 90 | + |
| 91 | + steps: |
| 92 | + - name: Checkout |
| 93 | + uses: actions/checkout@v2 |
| 94 | + |
| 95 | + - name: Docker Build |
| 96 | + uses: docker/build-push-action@v1 |
| 97 | + with: |
| 98 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 99 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 100 | + repository: timoa/nodejs-encryption-api-example |
| 101 | + tags: latest |
| 102 | + |
0 commit comments