fix: Continue to work on GH action. #5
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: Static Code Analysis | |
on: | |
push: | |
branches: | |
- main | |
- feat/static-analysis | |
pull_request: | |
branches: | |
- main | |
- feat/static-analysis | |
workflow_dispatch: | |
jobs: | |
analyze: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
lfs: true | |
# Cache | |
- uses: actions/cache@v3 | |
with: | |
path: Library | |
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} | |
restore-keys: | | |
Library- | |
- name: Set up .NET Core | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: '6.0.x' | |
# Build | |
- name: Build project | |
uses: game-ci/unity-builder@v4 | |
env: | |
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
targetPlatform: StandaloneLinux64 | |
- name: Generate project files | |
run: | | |
# Run Unity in batch mode to generate .sln and .csproj files | |
/opt/unity/Editor/Unity -batchmode -quit -projectPath . -executeMethod UnityEditor.SyncVS.SyncSolution | |
- name: Restore NuGet packages | |
run: | | |
# Assuming Unity generates files in the root or known subdirectory | |
dotnet restore UnityProject/MyUnityProject.sln # Update with the correct path | |
- name: Run static code analysis | |
run: | | |
dotnet build UnityProject/MyUnityProject.sln /warnaserror /p:TreatWarningsAsErrors=true # Update with the correct path |