-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60a2918
commit bc1773d
Showing
1 changed file
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
name: CI/CD for .NET REST API and Angular Frontend | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build-and-test: | ||
runs-on: ubuntu-latest | ||
|
||
services: | ||
mysql: | ||
image: mysql:5.7 | ||
ports: | ||
- 3306:3306 | ||
options: >- | ||
--health-cmd="mysqladmin ping --silent" | ||
--health-interval=10s | ||
--health-timeout=5s | ||
--health-retries=3 | ||
env: | ||
MYSQL_ROOT_PASSWORD: root | ||
MYSQL_DATABASE: testdb | ||
|
||
strategy: | ||
matrix: | ||
dotnet-version: ['6.x'] | ||
node-version: ['16.x'] | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
# Set up .NET | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: ${{ matrix.dotnet-version }} | ||
|
||
- name: Restore .NET dependencies | ||
run: dotnet restore ./Server/MotoDev # Specify the folder for the .NET app here | ||
|
||
- name: Build .NET project | ||
run: dotnet build ./Server/MotoDev --no-restore --configuration Release # Specify the folder for the .NET app here | ||
|
||
- name: Run .NET tests | ||
run: dotnet test ./Server/MotoDev --no-build --verbosity normal # Specify the folder for the .NET app here | ||
|
||
# Set up Node.js | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Install Angular dependencies | ||
run: npm install | ||
working-directory: ./Client/MotoDev # Specify the folder for the Angular app here | ||
|
||
- name: Run Angular tests | ||
run: npm test -- --watch=false --browsers=ChromeHeadless | ||
working-directory: ./Client/MotoDev # Specify the folder for the Angular app here | ||
|
||
- name: Build Angular project | ||
run: npm run build -- --prod | ||
working-directory: ./Client/MotoDev # Specify the folder for the Angular app here | ||
|
||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: build-and-test | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v2 | ||
with: | ||
dotnet-version: '6.x' | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '16.x' | ||
|
||
- name: Install dependencies and build Angular project | ||
run: | | ||
npm install | ||
npm run build -- --prod | ||
working-directory: ./Client/MotoDev # Specify the folder for the Angular app here | ||
|
||
- name: Publish .NET API | ||
run: | | ||
dotnet publish ./Server/MotoDev -c Release -o publish # Specify the folder for the .NET app here | ||
# Add your deployment script here (e.g., copy files to a server or upload to a cloud service) |