Skip to content

Create health-check.yml (#71) #38

Create health-check.yml (#71)

Create health-check.yml (#71) #38

Workflow file for this run

name: Build & Deploy
on:
push:
branches: [ main ]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build
runs-on: windows-latest
outputs:
solution: ${{ steps.outvars.outputs.solution }}
version: ${{ steps.outvars.outputs.version }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Java
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: 19.0.2+7
- name: Set environment variables
id: envvars
run: |
echo "solution=$([io.path]::GetFileNameWithoutExtension($(Get-ChildItem -Path .\* -Include *.sln)))" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "projectPath=$((Get-ChildItem -Path .\Src\ -Directory | Select-Object -First 1).Name)" | Out-File -FilePath $env:GITHUB_ENV -Append
echo "sonar_key=$("${{ github.repository }}" -replace "/","_")" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar
- name: Cache SonarCloud scanner
id: cache-sonar-scanner
uses: actions/cache@v3
with:
path: .\.sonar\scanner
key: ${{ runner.os }}-sonar-scanner
restore-keys: ${{ runner.os }}-sonar-scanner
- name: Install SonarCloud scanner
if: steps.cache-sonar-scanner.outputs.cache-hit != 'true'
shell: powershell
run: |
New-Item -Path .\.sonar\scanner -ItemType Directory
dotnet tool update dotnet-sonarscanner --tool-path .\.sonar\scanner
- name: Setup MSBuild Path
uses: microsoft/[email protected]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Setup Nuget
uses: NuGet/[email protected]
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Setup VSTest
uses: darenm/[email protected]
- name: Restore NuGet Packages
run: nuget restore "${{ env.solution }}.sln"
- name: Build Release
run: msbuild "${{ env.solution }}.sln" -m /p:Configuration=Release /p:DeployOnBuild=true /p:PublishProfile=FolderPublish /p:RestoreLockedMode=true -verbosity:detailed
- name: Set version from file
id: ver
run: |
echo "version=$(type Src/${{ env.projectPath }}/Properties/Version.txt)" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Set env variables to output
id: outvars
run: |
echo "solution=${{ env.solution }}" >> $env:GITHUB_OUTPUT
echo "version=${{ env.version }}" >> $env:GITHUB_OUTPUT
- name: Upload Core artifacts
uses: actions/upload-artifact@v3
with:
name: Core
path: Publish\Core
deploy_core:
name: Deploy Core
needs: build
runs-on: ubuntu-latest
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: Core
- name: Upload to ftp
uses: sebastianpopp/ftp-action@releases/v2
with:
host: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
remoteDir: Core
forceSsl: true
create_release:
name: Create Release
needs: [build, deploy_core]
runs-on: ubuntu-latest
steps:
- name: Download artifact Core
uses: actions/download-artifact@v3
with:
name: Core
path: Core
- name: Zip artifact
run: |
zip -r Core.zip ./Core/*
- name: Create Release
id: create_release
uses: ncipollo/[email protected]
with:
allowUpdates: true
draft: false
makeLatest: true
tag: v${{ needs.build.outputs.version }}
name: Release v${{ needs.build.outputs.version }}
generateReleaseNotes: true
body: Release ${{ needs.build.outputs.version }} of ${{ needs.build.outputs.solution }}
- name: Upload Core
id: upload_core
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Core.zip
asset_name: Core.zip
asset_content_type: application/zip
- name: Send Webhook
uses: distributhor/workflow-webhook@v3
env:
webhook_type: 'json-extended'
event_name: 'release'
webhook_url: ${{ secrets.RELEASE_WEBHOOK_URL }}
webhook_secret: '{"x-github-release-token": "${{ secrets.RELEASE_WEBHOOK_TOKEN }}"}'
data: '{ "tag_name": "v${{ needs.build.outputs.version }}", "assets": [{ "name" : "Core.zip", "browser_download_url": "${{ steps.upload_core.outputs.browser_download_url }}" } ] }'
cleanup:
name: Cleanup
needs: create_release
runs-on: ubuntu-latest
steps:
- name: Remove artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: "*"