2024-07-23 16:15:14 +08:00

45 lines
1.2 KiB
YAML

# This workflow will build a .NET project and push the built files to the latest branch
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-net
name: .NET
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Fetch all history for all branches
- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: 8.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
run: dotnet build --no-restore
- name: Test
run: dotnet test --no-build --verbosity normal
- name: Archive build output
run: |
mkdir -p build_output
cp -r ./bin/Debug/net8.0/* build_output/
- name: Commit and push to latest
if: success()
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git checkout latest || git checkout -b latest
cp -r build_output/* .
git add .
git commit -m "Update build output from master"
git push origin latest