Skip to content

Cannot run unity-license-activate on Github actions #68

@mgarbade

Description

@mgarbade

I can run the unity-license-activate code successfully on my local machine (Windows 10 Pro, WSL2) doing

in Powershell

Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\2020.3.39f1\Editor\Unity.exe" -ArgumentList "-quit -batchmode -createManualActivationFile -logfile"

then in WSL2:

          npm install -g unity-verify-code
          git clone -b ci https://github.com/homuler/unity-license-activate.git
          cd unity-license-activate
          npm install
          cd ..
          npm install -g ./unity-license-activate
          unity-license-activate "$UNITY_EMAIL" "$UNITY_PASSWORD" Unity_v2020.3.39f1.alf --authenticator-key "$UNITY_TOTP_KEY"

however when I'm using the code inside a Github Actions file it crashes:

name: Run Tests on Windows
on:
  workflow_call:
    secrets:
      UNITY_EMAIL:
        required: true
      UNITY_PASSWORD:
        required: true
      UNITY_TOTP_KEY:
        required: true
jobs:

  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os:
          - windows-2019
        unity:
          - { version: "2020.3.36f1", changeset: "71f96b79b9f0" }
    steps:
      - name: Install UnityHub
        uses: crazy-max/ghaction-chocolatey@v2
        with:
          args: install unity-hub -y
      - name: Install UnityEditor
        run: |
          Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity Hub\Unity Hub.exe" -ArgumentList "-- --headless install --version ${{ matrix.unity.version }} --changeset ${{ matrix.unity.changeset }}"
          exit 0

      - name: Generate a license activation file
        run: |
          Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${{ matrix.unity.version }}\Editor\Unity.exe" -ArgumentList "-quit -batchmode -createManualActivationFile -logfile"
          exit 0
      - name: Request a Unity license file
        env:
          UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
          UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}
          UNITY_TOTP_KEY: ${{ secrets.UNITY_TOTP_KEY }}
        continue-on-error: true        # Add this line to get pass the error flag
        run: |
          npm install -g unity-verify-code
          git clone -b ci https://github.com/homuler/unity-license-activate.git
          cd unity-license-activate
          npm install
          cd ..
          npm install -g ./unity-license-activate
          unity-license-activate "$env:UNITY_EMAIL" "$env:UNITY_PASSWORD" Unity_v${{ matrix.unity.version }}.alf --authenticator-key "$env:UNITY_TOTP_KEY"

      # Add the error handling step here!
      - name: 🩺 Upload error screenshot
        uses: actions/upload-artifact@v1
        with:
          name: screenshot_error
          path: error.png
      
      - name: Activate License
        run: |
          $ulf_file = Get-Item Unity_*.ulf
          $process = Start-Process -NoNewWindow -Wait -PassThru "C:\Program Files\Unity\Hub\Editor\${{ matrix.unity.version }}\Editor\Unity.exe" -ArgumentList "-batchmode -nographics -logFile -quit -manualLicenseFile $ulf_file"
          $ulf_file.Delete()

          if ($process.ExitCode -ne 1)
          {
            exit $process.ExitCode
          }

Here is the error.png screenshot:
error

This is a strange message that I never get when I manually login to Unity-id through my browser. My hunch is that Github Actions uses some virtual machine with an IP that points to China or some other country that is restricted by the Unity-License server... 🤔

Anyway, I'm not sure how to debug this, as I cannot reproduce the error locally.

Here some more Error logs from Github actions:

1m 22s
Run npm install -g unity-verify-code

added 9 packages, and audited [1](https://github.com/movebook/CI-CD-Unity-Windows/actions/runs/3523079417/jobs/5906806661#step:5:1)0 packages in 4s

found 0 vulnerabilities
Cloning into 'unity-license-activate'...

added 59 packages, and audited 60 packages in 12s

8 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

added 1 package, and audited 3 packages in 423ms

found 0 vulnerabilities
[INFO] Navigating to https://license.unity3d.com/manual
[INFO] Start login...
[INFO] 2FA (Authenticator App)
[INFO] Drag license file...
TimeoutError: waiting for selector `input[name="licenseFile"]` failed: timeout 30000ms exceeded
    at new WaitTask (D:\a\CI-CD-Unity-Windows\CI-CD-Unity-Windows\unity-license-activate\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:528:34)
    at DOMWorld.waitForSelectorInPage (D:\a\CI-CD-Unity-Windows\CI-CD-Unity-Windows\unity-license-activate\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:432:26)
    at Object.internalHandler.waitFor (D:\a\CI-CD-Unity-Windows\CI-CD-Unity-Windows\unity-license-activate\node_modules\puppeteer\lib\cjs\puppeteer\common\QueryHandler.js:31:77)
    at DOMWorld.waitForSelector (D:\a\CI-CD-Unity-Windows\CI-CD-Unity-Windows\unity-license-activate\node_modules\puppeteer\lib\cjs\puppeteer\common\DOMWorld.js:323:29)
    at Frame.waitForSelector (D:\a\CI-CD-Unity-Windows\CI-CD-Unity-Windows\unity-license-activate\node_modules\puppeteer\lib\cjs\puppeteer\common\FrameManager.js:942:51)
    at Page.waitForSelector (D:\a\CI-CD-Unity-Windows\CI-CD-Unity-Windows\unity-license-activate\node_modules\puppeteer\lib\cjs\puppeteer\common\Page.js:2370:33)
    at Object.start (D:\a\CI-CD-Unity-Windows\CI-CD-Unity-Windows\unity-license-activate\lib\activate.js:84:[16](https://github.com/movebook/CI-CD-Unity-Windows/actions/runs/3523079417/jobs/5906806661#step:5:17))
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Error:  Something went wrong, please check the screenshot `error.png`
Error: Process completed with exit code 1.

and later

Run $ulf_file = Get-Item Unity_*.ulf
[LicensingClient] Channel doesn't exist: "LicenseClient-runneradmin"
[Licensing::Module] Successfully launched the LicensingClient (PId: 6096)
[Licensing::Module] Successfully connected to LicensingClient on channel: "LicenseClient-runneradmin" (connect: 0.53s, validation: 0.07s, handshake: 1.16s)
[Licensing::Module] Connected to LicensingClient (PId: 6096, launch time: 0.00, total connection time: 1.75s)
Entitlement-based licensing initiated
[LicensingClient] Licenses updated successfully

 Load manual activation license file.

LICENSE SYSTEM [2022[11](https://github.com/movebook/CI-CD-Unity-Windows/actions/runs/3523079417/jobs/5906806661#step:7:12)22 11:58:42] Load license file from: 

LICENSE SYSTEM [20221[12](https://github.com/movebook/CI-CD-Unity-Windows/actions/runs/3523079417/jobs/5906806661#step:7:13)2 11:58:42] Failed to load license file from: 

 License file loaded.
InvalidOperation: D:\a\_temp\86ab[20](https://github.com/movebook/CI-CD-Unity-Windows/actions/runs/3523079417/jobs/5906806661#step:7:21)cf-959e-4084-b744-58bebf10f575.ps1:4
Line |
   4 |  $ulf_file.Delete()
     |  ~~~~~~~~~~~~~~~~~~
     | You cannot call a method on a null-valued expression.

Exiting without the bug reporter. Application will terminate with return code 1

the latter seems just to be a follow-up error from the problem that there is no license file

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions