-
Notifications
You must be signed in to change notification settings - Fork 306
138 lines (121 loc) · 4.82 KB
/
ci-cd.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
132
133
134
135
136
137
138
name: CI/CD
on:
push:
branches:
- "*" # Trigger on push to any branch
pull_request:
branches:
- "*" # Trigger on pull request to any branch
jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
# Checkout the repository to the runner
- name: Checkout repository
uses: actions/checkout@v3
# Set up Node.js environment
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
# # Install client dependencies
# - name: Install client dependencies
# working-directory: src/app/client
# run: yarn install --no-progress --production=true
# # Build the client
# - name: Build client
# working-directory: src/app/client
# run: npm run build
# # List all files after the build
# - name: List all files after build
# working-directory: src/app/client
# run: find . -type f
# # Check if the dist directory exists and list its contents
# - name: Check if dist directory exists and list contents
# working-directory: src/app/client
# run: |
# if [ -d dist ]; then
# echo "dist directory exists. Listing contents:"
# ls -l dist
# else
# echo "dist directory does not exist"
# fi
# # Move index.html to index.ejs if it exists
# - name: Move index.html to index.ejs if it exists
# working-directory: src/app/client
# run: |
# if [ -f dist/index.html ]; then
# mv dist/index.html dist/index.ejs
# else
# echo "File dist/index.html does not exist"
# fi
# # Set up server directories
# - name: Set up server directories
# run: mkdir -p $GITHUB_WORKSPACE/app_dist
# # Copy server files to the destination directory
# - name: Copy server files
# run: |
# cp -r src/app/libs src/app/helpers src/app/proxy src/app/resourcebundles src/app/package.json src/app/framework.config.js src/app/sunbird-plugins src/app/routes src/app/constants src/app/controllers src/app/server.js $GITHUB_WORKSPACE/app_dist/
# shell: /usr/bin/bash -e {0}
# # Install server dependencies
# - name: Install server dependencies
# working-directory: ${{ github.workspace }}/app_dist
# run: yarn install --ignore-engines --no-progress --production=true
# # Run server build script
# - name: Run server build script
# working-directory: ${{ github.workspace }}/app_dist
# run: node helpers/resourceBundles/build.js -task="phraseAppPull"
# Execute test cases using JEST
# - name: Execute test cases using JEST
# working-directory: src/app/client
# run: |
# yarn config set ignore-engines true
# yarn install
# npm run test:ci
# Install Sonar Scanner
# - name: Install Sonar Scanner
# run: |
# cd /tmp
# wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
# sudo apt-get install -y unzip
# unzip sonar-scanner-cli-5.0.1.3006-linux.zip
# cd -
# # Run SonarScanner for frontend (Angular)
# - name: Run SonarScanner for frontend
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# run: |
# /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \
# -Dsonar.projectKey=your_frontend_project_key \
# -Dsonar.sources=src \
# -Dsonar.host.url=https://sonarcloud.io \
# -Dsonar.organization=your_organization \
# -Dsonar.login=$SONAR_TO
# - name: Run Sonar Scanner
# env:
# SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# run: |
# /tmp/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner \
# -Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \
# -Dsonar.sources=src/app/client/src \
# -Dsonar.organization=sunbird-ed \
# -Dsonar.host.url=https://sonarcloud.io \
# -Dsonar.login=$SONAR_TOKEN
# Install SonarScanner globally using npm
- name: Install SonarScanner
run:
npm install -g sonarqube-scanner
# Debug: Print the masked SONAR_TOKEN
- name: Print SONAR_TOKEN
run: echo "SONAR_TOKEN=${{ secrets.SONAR_TOKEN }}PWR****123"
# Run SonarScanner in the specified directory
- name: Run SonarScanner
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: |
sonar-scanner \
-Dsonar.projectKey=Sunbird-Ed_SunbirdEd-portal \
-Dsonar.organization=your_organization \
-Dsonar.sources=src/app/client/src \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=$SONAR_TOKEN