Create health-check.yml #11
Workflow file for this run
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
name: Build & Bump Version | |
on: | |
push: | |
branches: | |
- '*' | |
- '*/*' | |
- '**' | |
- '!main' | |
paths-ignore: | |
- "**/Properties/AssemblyInfo.cs" | |
- "**/Properties/Version.txt" | |
workflow_dispatch: | |
concurrency: | |
group: bump-version | |
cancel-in-progress: true | |
env: | |
GHA_URL: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
jobs: | |
updateVersion: | |
name: Build & Patch | |
runs-on: self-hosted | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Generate a token | |
id: generate_token | |
uses: tibdex/[email protected] | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.APP_PRIVATE_KEY }} | |
- name: Update PR with comment (build started) | |
uses: mshick/add-pr-comment@v2 | |
with: | |
repo-token: ${{ steps.generate_token.outputs.token }} | |
refresh-message-position: true | |
message-id: 'begin' | |
message: | | |
**Build debug & Version bump:** :beginner: [Build started](${{ env.GHA_URL }}) | |
- name: Generate check | |
uses: LouisBrunner/[email protected] | |
id: generate_check | |
if: always() | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
name: 'Build & Bump Version' | |
status: 'in_progress' | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Check for changes in Src/ directory | |
uses: dorny/paths-filter@v2 | |
id: changes | |
with: | |
filters: | | |
src: | |
- "Src/**" | |
- name: Set solution name | |
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 | |
- name: Update PR with comment (build started solution) | |
uses: mshick/add-pr-comment@v2 | |
if: steps.changes.outputs.src == 'true' | |
with: | |
repo-token: ${{ steps.generate_token.outputs.token }} | |
refresh-message-position: true | |
message-id: 'begin' | |
message: | | |
**Build debug & Version bump:** :beginner: [Building ${{ env.solution }}.sln](${{ env.GHA_URL }}) | |
- name: Update PR with comment (build started solution) | |
uses: mshick/add-pr-comment@v2 | |
if: steps.changes.outputs.src == 'false' | |
with: | |
repo-token: ${{ steps.generate_token.outputs.token }} | |
refresh-message-position: true | |
message-id: 'begin' | |
message: | | |
**Build debug & Version bump:** :alien: [Not building ${{ env.solution }}.sln](${{ env.GHA_URL }}), no source files changed. | |
- name: Add MSBuild to PATH | |
uses: microsoft/[email protected] | |
if: steps.changes.outputs.src == 'true' | |
with: | |
msbuild-architecture: x64 | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
- name: Setup Nuget | |
uses: nuget/setup-nuget@v1 | |
if: steps.changes.outputs.src == 'true' | |
env: | |
ACTIONS_ALLOW_UNSECURE_COMMANDS: true | |
- name: Restore NuGet packages | |
if: steps.changes.outputs.src == 'true' | |
run: nuget restore "${{ env.solution }}.sln" | |
- name: Build Debug | |
if: steps.changes.outputs.src == 'true' | |
run: msbuild "${{ env.solution }}.sln" /p:Configuration=Debug -verbosity:detailed -flp1:"logfile=errors.txt;errorsonly" -flp2:"logfile=warnings.txt;warningsonly" | |
- name: Set version from file | |
if: steps.changes.outputs.src == 'true' | |
run: | | |
echo "version=$(type Src/${{ env.projectPath }}/Properties/Version.txt)" | Out-File -FilePath $env:GITHUB_ENV -Append | |
- name: Read warnings.txt | |
uses: andstor/file-reader-action@v1 | |
if: steps.changes.outputs.src == 'true' | |
id: warnings | |
with: | |
path: warnings.txt | |
- name: Read errors.txt | |
uses: andstor/file-reader-action@v1 | |
if: steps.changes.outputs.src == 'true' | |
id: errors | |
with: | |
path: errors.txt | |
- name: Update PR with comment (version) | |
uses: mshick/add-pr-comment@v2 | |
if: steps.changes.outputs.src == 'true' | |
with: | |
repo-token: ${{ steps.generate_token.outputs.token }} | |
refresh-message-position: true | |
message-id: 'version' | |
message: | | |
**Build debug & Version bump:** :dart: [Build succeeded](${{ env.GHA_URL }}) - New version: ${{ env.version }} | |
- name: Set check as successfully before new commit | |
uses: LouisBrunner/[email protected] | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
conclusion: 'success' | |
check_id: ${{ steps.generate_check.outputs.check_id }} | |
output: | | |
{"summary":"New version: ${{ env.version }}"} | |
- name: Setup GIT config | |
if: steps.changes.outputs.src == 'true' | |
run: | | |
git config user.name "net-framework-updater[bot]" | |
git config user.email "136581072+net-framework-updater[bot]@users.noreply.github.com" | |
git config --global --add --bool push.autoSetupRemote true | |
- name: Commit and Push | |
if: steps.changes.outputs.src == 'true' | |
run: | | |
git add . | |
git commit -a -m "Version bump (CI)" | |
echo "sha1=$(git rev-parse HEAD)" | Out-File -FilePath $env:GITHUB_ENV -Append | |
git push | |
- name: Update PR with comment | |
uses: mshick/add-pr-comment@v2 | |
if: always() && steps.changes.outputs.src == 'true' | |
with: | |
repo-token: ${{ steps.generate_token.outputs.token }} | |
refresh-message-position: true | |
message-id: 'final' | |
message: | | |
**Build debug & Version bump:** :white_check_mark: [Successfully builded and patched](${{ env.GHA_URL }}) **${{ env.solution }}.sln**. | |
**Version:** :hash: ${{ env.version }} | |
**Warnings:** :warning: | |
``` | |
${{ steps.warnings.outputs.contents }} | |
``` | |
message-failure: | | |
**Build debug & Version bump:** :x: [Failed](${{ env.GHA_URL }}) | |
**Errors:** :no_entry: | |
``` | |
${{ steps.errors.outputs.contents }} | |
``` | |
message-cancelled: | | |
**Build debug & Version bump:** :o: [Cancelled](${{ env.GHA_URL }}) | |
- name: Set check as successfully after new commit | |
uses: LouisBrunner/[email protected] | |
if: steps.changes.outputs.src == 'true' | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
conclusion: 'success' | |
name: 'Build & Bump Version' | |
output: | | |
{"summary":"New version: ${{ env.version }}"} | |
- name: Update check run status (Success) | |
uses: guibranco/[email protected] | |
if: success() && steps.changes.outputs.src == 'true' | |
with: | |
authToken: ${{ steps.generate_token.outputs.token }} | |
context: 'Build & Bump Version' | |
description: 'Build ${{ env.solution}}.sln - Version: ${{ env.version }}' | |
state: 'success' | |
sha: ${{ env.sha1 }} | |
target_url: ${{ env.GHA_URL }} | |
- name: Update check run status (Failure or Cancellation) | |
uses: guibranco/[email protected] | |
if: failure() || cancelled() | |
with: | |
authToken: ${{ steps.generate_token.outputs.token }} | |
context: 'Build & Bump Version' | |
description: ${{ job.status }} | |
state: 'failure' | |
sha: ${{ github.event.pull_request.head.sha || github.sha }} | |
target_url: ${{ env.GHA_URL }} |