diff --git a/.github/workflows/master_time-tracker-ui.yml b/.github/workflows/CD-time-tracker-ui.yml similarity index 65% rename from .github/workflows/master_time-tracker-ui.yml rename to .github/workflows/CD-time-tracker-ui.yml index 4b981c4ac..50424f661 100644 --- a/.github/workflows/master_time-tracker-ui.yml +++ b/.github/workflows/CD-time-tracker-ui.yml @@ -1,30 +1,33 @@ # Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy # More GitHub Actions for Azure: https://github.com/Azure/actions -name: Build and deploy Node.js app to Azure Web App - time-tracker-ui +name: CD process to deploy to App-Service service on: - push: + # Trigger the workflow on pull request but only for the master branch + pull_request: + types: [closed] branches: - master jobs: build-and-deploy: + name: Deploy to Azure runs-on: ubuntu-latest - + timeout-minutes: 60 steps: - - uses: actions/checkout@master + - name: Checkout of master + uses: actions/checkout@master - name: Set up Node.js version uses: actions/setup-node@v1 with: node-version: '12.x' - - name: npm install, build, and test + - name: 'run: npm install and build' run: | npm install - npm run build --if-present -# npm run test --if-present + npm run build --prod --if-present - name: 'Deploy to Azure Web App' uses: azure/webapps-deploy@v1 diff --git a/.github/workflows/CI-time-tracker-ui.yml b/.github/workflows/CI-time-tracker-ui.yml new file mode 100644 index 000000000..41d115b9c --- /dev/null +++ b/.github/workflows/CI-time-tracker-ui.yml @@ -0,0 +1,50 @@ +name: CI process for time-tracker app + +on: + # Trigger the workflow on push or pull request + push: + branches: + - '*' + - '*/*' + - '!master' + + pull_request: + types: [opened, edited, reopened, synchronize] + branches: + - master + +jobs: + security-audit: + name: Running npm audit + runs-on: ubuntu-latest + timeout-minutes: 60 + steps: + - name: Clone and checkout branch + uses: actions/checkout@master + + - name: Set up Node.js version + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - name: Security Audit + run: npm audit --audit-level=moderate + + ci-test: + name: Running unit tests + runs-on: ubuntu-latest + timeout-minutes: 90 + steps: + - name: Clone and checkout branch + uses: actions/checkout@master + + - name: Set up Node.js version + uses: actions/setup-node@v1 + with: + node-version: '12.x' + + - name: Install dependencies + run: npm install + + - name: Run the test + run: npm run ci-test --if-present diff --git a/package.json b/package.json index 27b88bce8..c17e0c62f 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "start": "ng serve", "build": "ng build", "test": "ng test", + "ci-test": "ng test --no-watch --no-progress --browsers ChromeHeadless", "lint": "ng lint", "e2e": "ng e2e" },