18
2021
Run Unity Cloud Build based on Github Commit message using Github Actions
This should had been easy, but unity cloud build system has every secret id hidden in different places and using different names..
- Create github action (click Actions from your repository)
- click “Skip this and set up a workflow yourself”
- copy ready to use script from: https://github.com/unitycoder/UnityCloudBuildGithubActions/blob/main/.github/workflows/main.yml
- you can modify “branches: [ main ]” if you are not using “main” branch
- you can modify the required commit messages, for android its the: “#BUILD_ANDROID”
- you can modify the required commit messages, for ios its the: “#BUILD_IOS”
- Add secrets to your repo Settings/Secrets
- collect secret keys from https://dashboard.unity3d.com , If you are invited as a collaborator check https://dashboard.unity3d.com/settings/account/guest-projects
- Select your cloud project
- get API_KEY from Devops/Settings page (at API Settings row)
- PROJECT_ID from Project/Settings page (top bar, settings icon next to project name)
- ORG_ID from your current dashboard (when viewing project). Looks something like https://dashboard.unity3d.com/organizations/[ORGIDHERE]/projects/..
- BUILD_TARGET_ID_ANDROID its from DevOps/Config/, those targets that you have deviced there. Click Basic info, its the “Target name:” row, this is actually Build Target ID (but unity named it as “Target name”) and for some reason it defaults to some bad id, like “Default Android”.
- Repeat for IOS if need it (or remove from script)
- Note: make it lower case, and replace spaces with – (minus), so “Default Android” becomes “default-android”
- Note: You can change this id by clicking that blue “edit basic info” link below the opened basic info panel. (not the top panel where it shows “basic info” in title)
- From “Edit Basic Info” you can now also disable [x] Auto Build (this would build on every commit), and set correct Branch if needed.
- Now make a commit on main branch, with commit message that includes “#BUILD_ANDROID”, then check from Cloud Build system that build gets started (can take less than 1 minute)
Script info:
// this line checks if commit message contains #BUILD_ANDROID string and only then it runs the curl POST messageif [[ "${{ github.event.commits[0].message }}" == "#BUILD_ANDROID" ]];
Errors:*1{"error":"Not authorized. User does not have correct permissions to perform this operation."}
Check your Secrets, probably bad ORG_ID.
{"error":"The requested object was not found."}
Check that your secret variables are correct name in the script (if secret is “BUILD_TARGET_ID”, maybe in the script you have “BUILD_TARGET_ID_ANDROID” ?)
*1: You can view log output from Actions/ All Workflows / click the action (has commit message and with green checkmark next to it), then click “build” (this job name was set in the actions script), then click “Run multi-line script”, to open that task log.
Related Posts
5 Comments + Add Comment
Leave a comment
Recent posts
- MotionVector Effect: Object “disappears” when paused
- [GreaseMonkey] Unity Forum Fixer
- UnityHub: Make Hub application background Translucent
- Customize SpriteShapeRenderer quality (but has issues)
- Editor tool: Copy selected gameobject’s names into clipboard as rows (for Excel)
- Editor tool: Replace string in selected gameobject’s names
- UnityHub: Enable built-in Login Dialog (no more browser login/logout issues!)
- Use TikTok-TTS in Unity (with WebRequest)
- Create Scene Thumbnail Image using OnSceneSaved & OnPreviewGUI
- webgl+javascript TTS
- Using Moonsharp (LUA) + Unity Webgl
- Using 3D gameobject prefabs with Unity Tilemap + NavMesh Surface
Recent Comments
- [Asset Store] Point Cloud Viewer & Tools on
- [Asset Store] Point Cloud Viewer & Tools on
- Vector3 maths for dummies! on
- UnityHub: Make Hub application background Translucent on
- UnityHub: Make Hub application background Translucent on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- Install Android SDK+JDK+NDK for Unity (without AndroidStudio or Unity Hub) on
- [Asset Store] Point Cloud Viewer & Tools on
GitHub action to retrieve a Unity project’s bundleVersion
https://github.com/KageKirin/get-unity-bundle-version
php scripts for custom webhooks
https://www.triplustutorials.be/codeexamples/share-your-unity-games-url-every-build/
It’s nice. Thanks.
tutorials on CI (Continuous Integration) using Unity and GitHub Actions
https://github.com/mackysoft/Unity-GitHubActions-Tutorials
Unity Addressables Post Build Script to upload to a server
https://forum.unity.com/threads/unity-addressables-post-build-script-to-upload-to-a-server.1149314/#post-7381676