Install dependencies before launching unity in copilot setup #74
Workflow file for this run
This file contains hidden or 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: "Copilot Setup Steps" | |
| # Automatically run the setup steps when they are changed to allow for easy validation, and | |
| # allow manual testing through the repository's "Actions" tab | |
| on: | |
| workflow_dispatch: | |
| push: | |
| paths: | |
| - .github/workflows/copilot-setup-steps.yml | |
| pull_request: | |
| paths: | |
| - .github/workflows/copilot-setup-steps.yml | |
| jobs: | |
| # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. | |
| copilot-setup-steps: | |
| runs-on: ubuntu-latest | |
| # Set the permissions to the lowest permissions possible needed for your steps. | |
| # Copilot will be given its own token for its operations. | |
| permissions: | |
| # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete. | |
| contents: read | |
| # NOTE: Unity version and changeset are embedded directly in the steps instead of using env variables | |
| # because Copilot coding agent doesn't properly use env parameters when setting up the environment. | |
| # Unity Version: 2022.3.22f1, Changeset: 887be4894c44 | |
| # You can define any steps you want, and they will run before the agent starts. | |
| # If you do not check out your code, Copilot will do this for you. | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cache Library folder | |
| uses: actions/cache@v4 | |
| with: | |
| path: Library | |
| key: Library-build-${{ github.ref }} | |
| restore-keys: | | |
| Library-build- | |
| - name: Set up vrc-get | |
| uses: anatawa12/sh-actions/setup-vrc-get@master | |
| - name: Add VPM Catalog repository | |
| run: vrc-get repo add https://vpm-catalog.vercel.app/index.json | |
| - name: Resolve VPM packages | |
| uses: nick-fields/retry@v3 | |
| with: | |
| timeout_minutes: 10 | |
| max_attempts: 5 | |
| retry_wait_seconds: 60 | |
| command: vrc-get resolve | |
| - run: vrc-get info project | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: 9.0.x | |
| - name: Setup Unity Hub | |
| run: | | |
| wget -qO - https://hub.unity3d.com/linux/keys/public | gpg --dearmor | sudo tee /usr/share/keyrings/Unity_Technologies_ApS.gpg > /dev/null | |
| sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/Unity_Technologies_ApS.gpg] https://hub.unity3d.com/linux/repos/deb stable main" > /etc/apt/sources.list.d/unityhub.list' | |
| sudo apt update | |
| sudo apt-get -y install unityhub | |
| - name: Cache Unity Editor | |
| id: cache-unity-editor | |
| uses: actions/cache@v4 | |
| with: | |
| path: ~/Unity/Hub/Editor | |
| key: Unity-Editor-2022.3.22f1-${{ github.head_ref || github.ref }} | |
| restore-keys: | | |
| Unity-Editor-2022.3.22f1- | |
| - name: Set Unity Editor path | |
| run: | | |
| UNITY_PATH="$HOME/Unity/Hub/Editor/2022.3.22f1/Editor/Unity" | |
| echo "UNITY_PATH=$UNITY_PATH" >> $GITHUB_ENV | |
| - name: Install Unity Editor | |
| run: | | |
| if [ ! -f "$HOME/Unity/Hub/Editor/2022.3.22f1/Editor/Unity" ]; then | |
| xvfb-run unityhub -- --headless install --version 2022.3.22f1 --changeset 887be4894c44 --module windows-mono | |
| else | |
| echo "Unity Editor already installed, skipping installation" | |
| fi | |
| - name: Set up pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: 'pnpm' | |
| cache-dependency-path: Website/pnpm-lock.yaml | |
| - run: cd Website && pnpm install --frozen-lockfile | |
| - name: Install uloop-cli | |
| run: pnpm install -g uloop-cli | |
| - name: Generate solution | |
| env: | |
| UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
| UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
| UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} | |
| run: | | |
| max_attempts=5 | |
| base_delay=30 | |
| for i in $(seq 1 "$max_attempts"); do | |
| if UNITY_COMMAND=${UNITY_PATH} xvfb-run ./.github/workflows/unity.sh -batchmode -nographics -logFile /dev/stdout -projectPath . -executeMethod Packages.Rider.Editor.RiderScriptEditor.SyncSolution -quit; then | |
| exit 0 | |
| fi | |
| if [ "$i" -lt "$max_attempts" ]; then | |
| delay=$((base_delay * 2 ** (i - 1))) | |
| echo "Attempt $i failed. Retrying in ${delay} seconds..." | |
| sleep "$delay" | |
| fi | |
| done | |
| exit 1 | |
| - name: Update uLoopMCP skills | |
| run: uloop skills install --claude |