diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 88bfbe7..729ca80 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -2,7 +2,10 @@ name: BuildApp on: workflow_dispatch: {} - + push: + branches: + - main + concurrency: group: build-${{ github.ref }} cancel-in-progress: false diff --git a/.gitea/workflows/hello.yml b/.gitea/workflows/hello.yml deleted file mode 100644 index cfba389..0000000 --- a/.gitea/workflows/hello.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: _debug-mount -on: { workflow_dispatch: {} } -jobs: - check: - runs-on: ubuntu-latest - steps: - - name: Who/where - run: | - set -e - echo "uname -a:"; uname -a || true - echo "--- cgroup ---"; cat /proc/1/cgroup || true - - name: Show docker image info - run: | - cat /etc/os-release || true - - name: Mounts & write marker - run: | - set -e - echo "== grep mount ==" - mount | grep -E 'runner-cache|ci-keys' || true - echo "== ls /runner-cache ==" - ls -la /runner-cache || true - echo "MARKER $(date -Iseconds)" | tee /runner-cache/__ok.txt - echo "OK" \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 5364539..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,113 +0,0 @@ -name: BuildApp -on: - #push: - # branches: - # - main - #pull_request: - # branches: - # - main - workflow_dispatch: - -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 - uses: actions/upload-artifact@v4 - with: - name: frontend - path: src/Frontend/dist - - 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: | - dotnet build DiunaBI.sln --configuration Release - dotnet build DiunaBI.Plugins.Morska/DiunaBI.Plugins.Morska.csproj --configuration Release - # Przygotuj katalog dla testów - 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/ - echo "✅ Plugins copied to test directory:" - 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 - rm -f client_secrets.Development.json - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: webapi - path: build/webapi \ No newline at end of file diff --git a/.github/workflows/buildScripts/downloadArtifacts.js b/.github/workflows/buildScripts/downloadArtifacts.js deleted file mode 100644 index 7b87384..0000000 --- a/.github/workflows/buildScripts/downloadArtifacts.js +++ /dev/null @@ -1,27 +0,0 @@ -module.exports = async ({ github, context, core, jobId, name }) => { - const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: jobId, - }); - if (artifacts.data.total_count === 0) { - core.setFailed("No artifacts found for jobID: " + jobId); - return false; - } - const artifact = artifacts.data.artifacts.find( - (artifact) => artifact.name === name - ); - if (!artifact) { - core.setFailed(`${name} not found in artifacts`); - return false; - } - const response = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: artifact.id, - archive_format: "zip" - }); - require('fs').writeFileSync(`${name}.zip`, Buffer.from(response.data)); - require('fs').mkdirSync(`./${jobId}/${name}`, { recursive: true }); - require('child_process').execSync(`unzip -o ${name}.zip -d ./${jobId}/${name}`); -}; diff --git a/.github/workflows/buildScripts/getLastBuildId.js b/.github/workflows/buildScripts/getLastBuildId.js deleted file mode 100644 index a82c0ed..0000000 --- a/.github/workflows/buildScripts/getLastBuildId.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = async ({ github, context }) => { - const { data: runs } = await github.rest.actions.listWorkflowRuns({ - owner: context.repo.owner, - repo: context.repo.repo, - workflow_id: "build.yml", - branch: "main", - status: "success", - per_page: 1, - }); - return runs.workflow_runs[0].id; -}; diff --git a/.github/workflows/buildScripts/replaceTokens.js b/.github/workflows/buildScripts/replaceTokens.js deleted file mode 100644 index 565cfdb..0000000 --- a/.github/workflows/buildScripts/replaceTokens.js +++ /dev/null @@ -1,38 +0,0 @@ -module.exports = async ({ github, context, core, jobId }) => { - - const frontendPath = `./${jobId}/frontend/diunaBI/browser/`; - const files = (require('fs').readdirSync(frontendPath).filter(file => file.endsWith('.js'))) - .map(file => `${frontendPath}${file}`); - if (files.length === 0) { - core.setFailed("Frontend JS files not found"); - return false; - } - - files.push(`./${jobId}/webapi/appsettings.json`); - files.push(`./${jobId}/webapi/client_secrets.json`); - - files.forEach(file => { - let data = require('fs').readFileSync(file, 'utf8'); - const regex = /#{(.*?)}#/g; - let match; - while (match = regex.exec(data)) { - const original = match[0]; - const token = match[1].replace(/-/g, '_').toUpperCase(); - const value = getValue(token, jobId); - console.log(`Replacing ${original} with ${value} for ${token}`); - if (!value) { - core.setFailed(`Token ${token} not found`); - return false; - } - data = data.replace(new RegExp(original, 'g'), value); - } - require('fs').writeFileSync(file, data, 'utf8'); - }); -} - -function getValue(token, jobId) { - if (token == 'BUILDID') { return jobId; } - const secrets = JSON.parse(process.env.SECRETS); - const variables = JSON.parse(process.env.VARIABLES); - return variables[token] || secrets[token]; -} \ No newline at end of file diff --git a/.github/workflows/release-morska.yml b/.github/workflows/release-morska.yml deleted file mode 100644 index 7ccc868..0000000 --- a/.github/workflows/release-morska.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Morska Release -on: - workflow_dispatch: - inputs: - job_id: - description: 'Job ID of the build to release' - required: false - -permissions: - actions: read - contents: read - -jobs: - release: - runs-on: ubuntu-latest - environment: Morska - - steps: - - uses: actions/checkout@v3 - - - name: Assign run ID if provided - if: ${{ github.event.inputs.job_id != '' }} - run: echo "job_id=${{ github.event.inputs.job_id }}" >> $GITHUB_ENV - - - name: Get last build ID - id: get-build-id - if: ${{ github.event.inputs.job_id == '' }} - uses: actions/github-script@v6 - with: - script: | - const script = require('./.github/workflows/buildScripts/getLastBuildId.js'); - const jobId = await script({github, context}); - core.setOutput("job_id", jobId); - - - name: Set job_id - if: ${{ github.event.inputs.job_id == '' }} - run: echo "job_id=${{ steps.get-build-id.outputs.job_id }}" >> $GITHUB_ENV - - name: Check job_id - run: | - if [ -z "${{ env.job_id }}" ]; then - echo "Error: job_id is empty" - exit 1 - fi - - - name: Download frontend artifacts - uses: actions/github-script@v6 - with: - script: | - const script = require('./.github/workflows/buildScripts/downloadArtifacts.js'); - await script({github, context, core, jobId: ${{env.job_id}}, name: 'frontend'}); - - - name: Download backend artifacts - uses: actions/github-script@v6 - with: - script: | - const script = require('./.github/workflows/buildScripts/downloadArtifacts.js'); - await script({github, context, core, jobId: ${{env.job_id}}, name: 'webapi'}); - - - name: Tokenize - uses: actions/github-script@v6 - env: - SECRETS: ${{ toJson(secrets) }} - VARIABLES: ${{ toJson(vars) }} - with: - script: | - const script = require('./.github/workflows/buildScripts/replaceTokens.js'); - await script({github, context, core, jobId: ${{env.job_id}} }); - - - name: Archive frontend artifacts - run: | - cd ${{env.job_id}}/frontend - zip -r ../DiunaBI-Morska-Frontend.zip . - - - name: Archive backend artifacts - run: | - cd ${{env.job_id}}/webapi - zip -r ../DiunaBI-Morska-WebApi.zip . - - - name: List artifacts - run: ls -la . - - - name: Send frontend archive to remote server - env: - SSH_PRIVATE_KEY: ${{ secrets.PROD_SRV_PRIVATE_KEY }} - run: | - echo "${SSH_PRIVATE_KEY}" > private_key - chmod 600 private_key - scp -i private_key -o StrictHostKeyChecking=no ./${{env.job_id}}/DiunaBI-Morska-Frontend.zip mz@bim-it.pl:./deployment/ - rm private_key - - - name: Send frontend archive to remote server - env: - SSH_PRIVATE_KEY: ${{ secrets.PROD_SRV_PRIVATE_KEY }} - run: | - echo "${SSH_PRIVATE_KEY}" > private_key - chmod 600 private_key - scp -i private_key -o StrictHostKeyChecking=no ./${{env.job_id}}/DiunaBI-Morska-WebApi.zip mz@bim-it.pl:./deployment/ - rm private_key - - - name: Run SSH commands on remote server - env: - SSH_PRIVATE_KEY: ${{ secrets.PROD_SRV_PRIVATE_KEY }} - run: | - echo "${SSH_PRIVATE_KEY}" > private_key - chmod 600 private_key - ssh -i private_key -o StrictHostKeyChecking=no mz@bim-it.pl << 'EOF' - ./deployment/DiunaBI-Morska.Release.sh - EOF - rm private_key \ No newline at end of file diff --git a/src/Frontend/src/app/views/main/main-view.component.html b/src/Frontend/src/app/views/main/main-view.component.html index ab564dc..238b0df 100644 --- a/src/Frontend/src/app/views/main/main-view.component.html +++ b/src/Frontend/src/app/views/main/main-view.component.html @@ -13,7 +13,7 @@ -  {{appVersion}} +  Build #{{appVersion}}
@@ -45,4 +45,4 @@
- \ No newline at end of file +