In pull_request context, GITHUB_REF_NAME is the PR number ('17'),
not the source branch. Cloning --branch 17 fails with
'Could not find remote branch 17 to clone'.
Use GITHUB_REF (refs/pull/N/head in PR context, refs/heads/<branch>
in push context) and fetch + checkout FETCH_HEAD. workflow_dispatch
falls back to the default branch.
61 lines
1.6 KiB
YAML
61 lines
1.6 KiB
YAML
# This workflow will build a .NET project
|
|
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
|
|
name: Dotnet build and test
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
logLevel:
|
|
description: 'Log level'
|
|
required: true
|
|
default: 'warning'
|
|
type: choice
|
|
options:
|
|
- info
|
|
- warning
|
|
- debug
|
|
tags:
|
|
description: 'Test scenario tags'
|
|
required: false
|
|
type: boolean
|
|
push:
|
|
branches: [ "main" ]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
jobs:
|
|
log-the-inputs:
|
|
runs-on: debian-latest
|
|
steps:
|
|
- run: |
|
|
echo "Log level: $LEVEL"
|
|
echo "Tags: $TAGS"
|
|
echo "Environment: $ENVIRONMENT"
|
|
env:
|
|
LEVEL: ${{ inputs.logLevel }}
|
|
TAGS: ${{ inputs.tags }}
|
|
|
|
build:
|
|
|
|
runs-on: docker
|
|
|
|
steps:
|
|
- name: Clone yavsc
|
|
run: |
|
|
cd "$RUNNER_WORKSPACE"
|
|
git clone https://forgejo.pschneider.fr/notazof/yavsc.git _src
|
|
cd _src
|
|
if [ -n "${GITHUB_REF:-}" ]; then
|
|
git fetch --depth 1 origin "$GITHUB_REF"
|
|
git checkout FETCH_HEAD
|
|
fi
|
|
git submodule update --init --recursive --depth 1
|
|
- name: Restore dependencies
|
|
working-directory: ${{ runner.workspace }}/_src
|
|
run: dotnet restore
|
|
- name: Build
|
|
working-directory: ${{ runner.workspace }}/_src
|
|
run: dotnet build --no-restore
|
|
- name: Test
|
|
working-directory: ${{ runner.workspace }}/_src
|
|
run: dotnet test --no-build --verbosity normal
|