Skip to content

[GitActions][build] Add option to be reusable #10

[GitActions][build] Add option to be reusable

[GitActions][build] Add option to be reusable #10

Workflow file for this run

name: 'Build'
on:
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: false
default: 'Manual run'
workflow_call:
push:
# paths:
# - '**.cs'
# - '**.csproj'
pull_request:
branches: [ master ]
paths:
- '**.cs'
- '**.csproj'
env:
# Disable the .NET logo in the console output.
DOTNET_NOLOGO: true
# Stop wasting time caching packages
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
# Disable sending usage data to Microsoft
DOTNET_CLI_TELEMETRY_OPTOUT: true
DOTNET_ADD_GLOBAL_TOOLS_TO_PATH: false
DOTNET_MULTILEVEL_LOOKUP: 0
PROJECT_PATH: .
CONFIGURATION: Release
# Set the build number in MinVer.
MINVERBUILDMETADATA: build.${{github.run_number}}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build ${{ matrix.os }} - dotnet ${{ matrix.dotnet }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest, macos-latest ]
steps:
- name: Print manual run reason
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Checkout
uses: actions/checkout@v4
with:
lfs: true
fetch-depth: 0
- name: Setup .NET (global.json)
uses: actions/setup-dotnet@v4
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
# Look to see if there is a cache hit for the corresponding requirements file
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget
- name: Restore
run: dotnet restore "${{ env.PROJECT_PATH }}"
- name: Build
run: >-
dotnet build "${{ env.PROJECT_PATH }}"
--configuration "${{ env.CONFIGURATION }}"
--no-restore
-p:ContinuousIntegrationBuild=true