Skip to content

Commit

Permalink
Testing github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
rz-georgiev authored Dec 2, 2024
1 parent 60a2918 commit bc1773d
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/dotnet.yml
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)

0 comments on commit bc1773d

Please sign in to comment.