Files
DiunaBI/.github/workflows/build.yml
Michał Zieliński c5d1a9fd28 build
2025-09-12 12:02:51 +02:00

159 lines
4.9 KiB
YAML

name: BuildApp
on:
# push:
# branches: [ main ]
# pull_request:
#branches: [ main ]
workflow_dispatch: {}
# (opcjonalnie) ogranicz równoległe runy
concurrency:
group: build-${{ github.ref }}
cancel-in-progress: false
jobs:
build-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Angular CLI
run: npm install -g @angular/cli
- name: Install PNPM
run: npm install -g pnpm
- name: Install dependencies
working-directory: src/Frontend
run: pnpm install
- name: Build Angular
working-directory: src/Frontend
run: ng build --configuration=production
- name: Upload artifact (frontend)
uses: https://github.com/actions/upload-artifact@v3
with:
name: frontend
path: |
src/Frontend/dist
if-no-files-found: error
retention-days: 7
build-backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.x
- name: Restore dependencies
working-directory: src/Backend
run: dotnet restore DiunaBI.sln
- name: Build solution and prepare plugins
working-directory: src/Backend
run: |
set -e
dotnet build DiunaBI.sln --configuration Release
dotnet build DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj --configuration Release
mkdir -p DiunaBI.Tests/bin/Release/net8.0/Plugins
cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Plugins.Morska.dll DiunaBI.Tests/bin/Release/net8.0/Plugins/
cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Core.dll DiunaBI.Tests/bin/Release/net8.0/Plugins/
ls -la DiunaBI.Tests/bin/Release/net8.0/Plugins/
- name: Run Tests
working-directory: src/Backend
run: |
dotnet add DiunaBI.Tests/DiunaBI.Tests.csproj package coverlet.collector
dotnet test DiunaBI.Tests/DiunaBI.Tests.csproj \
--configuration Release \
--no-restore \
--logger "trx;LogFileName=test-results.trx" \
--collect:"XPlat Code Coverage" \
--filter "Category!=LocalOnly"
- name: Publish Test Results
uses: actions/upload-artifact@v4
if: success() || failure()
with:
name: test-results
path: |
src/Backend/DiunaBI.Tests/TestResults/*.trx
src/Backend/DiunaBI.Tests/TestResults/**/coverage.cobertura.xml
- name: Publish WebAPI
if: success()
working-directory: src/Backend
run: |
dotnet publish DiunaBI.WebAPI/DiunaBI.WebAPI.csproj \
--configuration Release \
--framework net8.0 \
--self-contained false \
--output ../../build/webapi
# Kopiuj pluginy do katalogu webapi
mkdir -p ../../build/webapi/Plugins
cp DiunaBI.Plugins.Morska/bin/Release/net8.0/DiunaBI.Plugins.Morska.dll ../../build/webapi/Plugins/
echo "✅ Plugins copied to webapi:"
ls -la ../../build/webapi/Plugins/
- name: Clean up sensitive files
working-directory: build/webapi
run: |
rm -f appsettings.Development.json || true
rm -f client_secrets.Development.json || true
- name: Upload artifact (webapi)
uses: https://github.com/actions/upload-artifact@v3
with:
name: webapi
path: build/webapi
if-no-files-found: error
retention-days: 7
copy-artifacts:
runs-on: ubuntu-latest
needs: [build-frontend, build-backend]
if: success()
steps:
- name: Download frontend artifacts
uses: https://github.com/actions/download-artifact@v3
with:
name: frontend
path: frontend
- name: Download webapi artifacts
uses: https://github.com/actions/download-artifact@v3
with:
name: webapi
path: webapi
- name: Store artifacts locally on runner
run: |
BUILD_DIR="/runner-cache/builds/$GITHUB_RUN_ID"
mkdir -p "$BUILD_DIR"
cp -r webapi/ "$BUILD_DIR/"
cp -r frontend/ "$BUILD_DIR/"
# Stwórz symlink na "latest"
mkdir -p /runner-cache/builds
ln -sfn "$BUILD_DIR" /runner-cache/builds/latest
# Zapisz metadane
echo "BUILD_TIME=$(date -Iseconds)" > "$BUILD_DIR/build-info.txt"
echo "COMMIT_SHA=${GITHUB_SHA}" >> "$BUILD_DIR/build-info.txt"
echo "BRANCH=${GITHUB_REF_NAME}" >> "$BUILD_DIR/build-info.txt"
echo "BUILD_ID=${GITHUB_RUN_ID}" >> "$BUILD_DIR/build-info.txt"
echo "✅ Build artifacts stored in: $BUILD_DIR"
ls -la "$BUILD_DIR/"