-
Notifications
You must be signed in to change notification settings - Fork 46
132 lines (111 loc) · 6.19 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: CI/CD GreenCityClient
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the dev branch
push:
branches: [master, dev]
pull_request:
branches: [master, dev]
env:
repository: client
dockerRepoName: skyere/greencity-front
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
# Steps
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
# - name: Set up Go
# uses: actions/setup-go@v3
# with:
# go-version: 1.18
# Runs a set of commands using the runners shell
- name: Install
run: |
npm install
wget https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_125.0.6422.76-1_amd64.deb
sudo apt-get install ./google-chrome-stable_125.0.6422.76-1_amd64.deb -y --allow-downgrades
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-6.0.0.4432-linux.zip
unzip sonar-scanner-cli-6.0.0.4432-linux.zip
sudo mv sonar-scanner-6.0.0.4432-linux /opt/sonar-scanner
- name: JS Linter
run: npm run lint
- name: CSS Linter
run: npm run stylelint
- name: Unit Tests
run: npx ng test --watch=false --progress=false --code-coverage=true --browsers=ChromeHeadless
- name: Sonar scan
#continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >
/opt/sonar-scanner/bin/sonar-scanner
-Dsonar.organization=ita-social-projects
-Dsonar.projectKey=ita-social-projects-green-city-client
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.sources=src
-Dsonar.exclusions=**/node_modules/**,src/app/component/user/components/profile/calendar/calendar-image.*,src/app/component/user/components/profile/calendar/calendar-week/calendar-image.*,src/environments/environment.prod.*,src/app/image-pathes/auth-images.*,src/app/image-pathes/profile-icons.*,src/app/image-pathes/profile-images.*,src/app/image-pathes/single-news-images.*,src/app/image-pathes/sign-in-icons.*,src/app/component/about/about-routing.module.*,src/app/component/about/about.module.*,src/app/component/eco-news/eco-news-routing.module.*,src/app/component/eco-news/eco-news.module.*,src/app/component/map/map-routing.module.*,src/app/component/map/map.module.*,src/app/component/user/user-routing.module.*,src/app/component/user/user.module.*,src/app/app-routing.module.*,src/app/component/shared/shared.module.*,src/app/component/admin/admin-routing.module.*,src/app/component/admin/admin.module.*,src/app/app.module.*,src/app/component/auth/auth.module.*,src/app/component/core/core.module.*,src/app/component/home/home.module.*,src/app/component/layout/layout.module.*,src/app/model/weekDays.model.*,src/app/model/achievement/AchievementDto.*,src/app/model/advice/AdviceDto.*,src/app/model/filtering/filter-discount-dto.model.*,src/app/model/filtering/filter-distance-dto.model.*,src/app/model/filtering/filter-place-dto.model.*,src/app/model/habit-fact/HabitFactDto.*,src/app/model/habit/HabitStatisticLogDto.*,src/app/model/habit/HabitStatisticMapDto.*,src/app/model/habit/HabitStatisticsDto.*,src/app/model/habit/NewHabitDto.*,src/app/component/home/models/NewsDto.*,src/app/service/subscription/SubscriptionDto.*,src/app/model/user/userFilterDto.model.*,src/app/store/effects/ecoEvents.effects.*,src/app/ubs/ubs-admin/components/ubs-admin-certificate/ubs-admin-certificate.component.*,src/app/shared/interceptors/interceptor.service.*,src/app/store/reducers/ecoEvents.reducer.*
-Dsonar.tests=src
-Dsonar.test.inclusions=**/*.spec.ts
-Dsonar.javascript.lcov.reportPaths=coverage/GreenCityClient/lcov.info
# - name: E2E Tests
# run: npx ng e2e --protractor-config=e2e/protractor-ci.conf.js
- name: Build
run: |
npx ng build --configuration=stage --base-href=/GreenCityClient/
# npx ng build --prod --delete-output-path --base-href=/GreenCityClient/ --outputPath=dist_aot && rm -rf dist_aot
# npx ng build --prod --base-href=/GreenCityClient/ --aot=false --build-optimizer=false
- name: Set outputs
run: echo "GITHUB_SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Docker Login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/[email protected]
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.dockerRepoName }}:test-${{ env.GITHUB_SHA_SHORT }}
- name: Docker Login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push Docker images
uses: docker/[email protected]
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.dockerRepoName }}:test-${{ env.GITHUB_SHA_SHORT }}
# - name: Kubernetes Set Context
# uses: Azure/[email protected]
# with:
# kubeconfig: ${{ secrets.KUBE_CONFIG }}
# - name: Kubernetes tests
# run: |
# cd chart-test
# go test -v ./...
# - name: Deploy 🚀
# if: ${{ github.event_name == 'push' }}
# uses: JamesIves/[email protected]
# with:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# BRANCH: gh-pages
# FOLDER: dist/GreenCityClient
# CLEAN: true