87 lines
2.4 KiB
YAML
87 lines
2.4 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [master, 'agent/*']
|
|
pull_request:
|
|
branches: [master]
|
|
|
|
jobs:
|
|
build-and-test:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Setup .NET
|
|
uses: actions/setup-dotnet@v4
|
|
with:
|
|
dotnet-version: '8.0.x'
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
cache-dependency-path: frontend/package-lock.json
|
|
|
|
- name: Restore .NET dependencies
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -n "${NUGET_CACHE_URL:-}" ]; then
|
|
echo "Using NuGet cache: ${NUGET_CACHE_URL}"
|
|
dotnet restore src/UsingCash.sln \
|
|
--source "${NUGET_CACHE_URL}" \
|
|
--source "https://api.nuget.org/v3/index.json" \
|
|
--ignore-failed-sources
|
|
else
|
|
dotnet restore src/UsingCash.sln
|
|
fi
|
|
|
|
- name: Build .NET
|
|
run: dotnet build src/UsingCash.sln --no-restore -c Release
|
|
|
|
- name: Run .NET tests
|
|
run: dotnet test src/UsingCash.sln --no-build -c Release --verbosity normal
|
|
|
|
- name: Install frontend dependencies
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
if [ -n "${NPM_REGISTRY_URL:-}" ]; then
|
|
echo "Using npm registry: ${NPM_REGISTRY_URL}"
|
|
npm config set registry "${NPM_REGISTRY_URL}"
|
|
fi
|
|
npm ci
|
|
working-directory: frontend
|
|
|
|
- name: Lint frontend
|
|
run: npm run lint
|
|
working-directory: frontend
|
|
|
|
- name: Build frontend
|
|
run: npm run build
|
|
working-directory: frontend
|
|
|
|
docker:
|
|
needs: build-and-test
|
|
runs-on: ubuntu-latest
|
|
if: github.ref == 'refs/heads/master'
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build Docker image
|
|
shell: bash
|
|
run: |
|
|
set -euo pipefail
|
|
build_args=()
|
|
if [ -n "${NUGET_CACHE_URL:-}" ]; then
|
|
build_args+=(--build-arg "NUGET_CACHE_URL=${NUGET_CACHE_URL}")
|
|
fi
|
|
if [ -n "${NPM_REGISTRY_URL:-}" ]; then
|
|
build_args+=(--build-arg "NPM_REGISTRY_URL=${NPM_REGISTRY_URL}")
|
|
fi
|
|
docker build "${build_args[@]}" -t using-cash:${{ github.sha }} -t using-cash:latest .
|
|
|
|
# Push to registry can be added when a registry is configured
|