ci: use global.json to install dotnet #44
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
# This workflow will build a .NET project | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net | |
name: Test & Build | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
workflow_dispatch: | |
# Edit this values to match your environment | |
env: | |
API_URL: "localhost:8080" | |
AZURE_TENANT_ID: "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaa" | |
AZURE_CLIENT_ID: "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaa" | |
VITE_AZURE_CLIENT_ID: aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaa | |
VITE_AZURE_AUTHORITY: https://login.microsoftonline.com/{your_tenant_id} | |
VITE_TODO_API_ENDPOINT_URL: http://localhost:8080 | |
VITE_TODO_API_SCOPES_READ: "[\"api://aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaa/ToDoList.Read\"]" | |
VITE_TODO_API_SCOPES_WRITE: "[\"api://aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaa/ToDoList.ReadWrite\"]" | |
jobs: | |
build-service: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v4 | |
with: | |
global-json-file: global.json | |
- run: corepack enable | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4.0.2 | |
with: | |
node-version: 20.x | |
- name: Restore dependencies | |
run: dotnet restore | |
- name: Restore tool dependencies | |
working-directory: ./src/Api | |
run: dotnet tool restore | |
- name: Test | |
run: dotnet test --verbosity normal | |
- name: Publish | |
run: dotnet publish --configuration Release --output ./publish | |
- name: Upload Open API Definiton | |
uses: actions/upload-artifact@v3 | |
with: | |
name: openapi.json | |
path: ./src/Api/bin/Release/net8.0/openapi.json | |
- name: Upload .NET artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: dotnet-artifacts | |
path: ./publish | |
build-client: | |
needs: build-service | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download Open API artifacts for generating the api types | |
uses: actions/download-artifact@v3 | |
with: | |
name: openapi.json | |
- run: corepack enable | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v4.0.2 | |
with: | |
node-version: 20.x | |
- name: Restore dependencies | |
working-directory: ./src/Client | |
run: npm ci | |
- name: Generate API | |
working-directory: ./src/Client | |
run: npm run api:generate ../../openapi.json | |
- name: Generate Router | |
working-directory: ./src/Client | |
run: npm run router:generate | |
- name: Type check | |
working-directory: ./src/Client | |
run: npm run type-check | |
- name: Check lint | |
working-directory: ./src/Client | |
run: npm run lint | |
- name: Run tests | |
working-directory: ./src/Client | |
run: npm run test --run | |
- name: Build | |
working-directory: ./src/Client | |
run: npm run build |