Open Voxelghiest opened 3 years ago
This sounds great!
Awesome!
From: Voxelghiest @.> Sent: Wednesday, June 30, 2021 2:55 PM To: RutgersGRID/devops-git-actions @.> Cc: Subscribed @.***> Subject: [RutgersGRID/devops-git-actions] Using GitHub Actions for Unity CI/CD (#7)
After quite a bit of searching and tinkering with GitHub actions, I have created an action that automatically builds a Unity project and then sends it to a remote server.
It took a bit of digging, but I was able to find an action on the GitHub marketplace called Unity Builderhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmarketplace%2Factions%2Funity-builder&data=04%7C01%7Crianders%40docs.rutgers.edu%7C35abc9dead134f38a3dd08d93bf89339%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637606761085575982%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=XdN4ytHn6Ev81ZfV0sVh56FUB78bN1nZF8NYFFqTzqI%3D&reserved=0 that does most of the hard work for me. However, the project is still in pre-release, so there were some quirks to using the action that I had to understand.
I looked through their repohttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgame-ci%2Funity-builder&data=04%7C01%7Crianders%40docs.rutgers.edu%7C35abc9dead134f38a3dd08d93bf89339%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637606761085575982%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=eHipw2sVPzf%2BTlFnjuyDDKrhdQ69ko6mHXUU2m4TazE%3D&reserved=0 and their documentation websitehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgame.ci%2Fdocs%2Fgithub%2Fgetting-started&data=04%7C01%7Crianders%40docs.rutgers.edu%7C35abc9dead134f38a3dd08d93bf89339%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637606761085585974%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=fJxbnKn6bSquGLr5pmEpqlYxVauIbaVZ6rcnV9rBAZc%3D&reserved=0 to try and comprehend how it works.
My best understanding is that the action uses a Docker image of the Unity editor to build a project on the runner provided by GitHub for its actions. To make it work, you have to add your own Unity license file as a secret in your repo so that the Unity image can be signed (directions for doing this are on their docs sitehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgame.ci%2Fdocs%2Fgithub%2Factivation&data=04%7C01%7Crianders%40docs.rutgers.edu%7C35abc9dead134f38a3dd08d93bf89339%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637606761085585974%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=dXbxgNwm5SkCOmCgghQlDl3EW8JiLTBVDemLVaVNTSo%3D&reserved=0).
Once you have the license file, you use the builder action like any other in your workflow, providing various arguments for things such as the build platform, version code, etc. (again, documented in detail on the docs sitehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgame.ci%2Fdocs%2Fgithub%2Fbuilder&data=04%7C01%7Crianders%40docs.rutgers.edu%7C35abc9dead134f38a3dd08d93bf89339%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637606761085595971%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=zCYjdhkQH%2By7ae3pVwUZVScpfs8yb36cqclpG%2B4XSEY%3D&reserved=0).
Building a project takes a solid few minutes, but there are potentially ways it could be improved by caching certain files.
Once the project is built, I am able to send it to a remote Ubuntu server using the Copy via SSHhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmarketplace%2Factions%2Fcopy-via-ssh&data=04%7C01%7Crianders%40docs.rutgers.edu%7C35abc9dead134f38a3dd08d93bf89339%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637606761085595971%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=5kDMlHNR1oy9wg%2FPrUnh%2FisEYeJALTaun0H5Ei4td%2B4%3D&reserved=0 action that I worked with previously.
To do all this, I worked with a test repo that I made myself. However, GitHub apparently has some sort of methodhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdocs.github.com%2Fen%2Factions%2Flearn-github-actions%2Fsharing-workflows-with-your-organization&data=04%7C01%7Crianders%40docs.rutgers.edu%7C35abc9dead134f38a3dd08d93bf89339%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637606761085605964%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=0Lo88DamA9SEMJ7mgICqQywGER%2BdojIyVzOWnKMIMOc%3D&reserved=0 to share my workflow with the entire RutgersGRID organization so that it can be centrally maintained and used in future projects. There are certainly potential improvements to be made, but this is a very promising start.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FRutgersGRID%2Fdevops-git-actions%2Fissues%2F7&data=04%7C01%7Crianders%40docs.rutgers.edu%7C35abc9dead134f38a3dd08d93bf89339%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637606761085605964%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Kmar8JsSfHBPePXHe40uNjlgBzJFYO15fL8optFM0Ag%3D&reserved=0, or unsubscribehttps://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAADTOXETOXBW6URXPOWGVMLTVNSATANCNFSM47S5UBRA&data=04%7C01%7Crianders%40docs.rutgers.edu%7C35abc9dead134f38a3dd08d93bf89339%7Cb92d2b234d35447093ff69aca6632ffe%7C1%7C0%7C637606761085615958%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=OBfPa6qnMHkbQW%2F2Ha8H%2FJjmZ6vZZVAJM0VYd%2Fdkczk%3D&reserved=0.
After quite a bit of searching and tinkering with GitHub actions, I have created an action that automatically builds a Unity project and then sends it to a remote server.
It took a bit of digging, but I was able to find an action on the GitHub marketplace called Unity Builder that does most of the hard work for me. However, the project is still in pre-release, so there were some quirks to using the action that I had to understand.
I looked through their repo and their documentation website to try and comprehend how it works.
My best understanding is that the action uses a Docker image of the Unity editor to build a project on the runner provided by GitHub for its actions. To make it work, you have to add your own Unity license file as a secret in your repo so that the Unity image can be signed (directions for doing this are on their docs site).
Once you have the license file, you use the builder action like any other in your workflow, providing various arguments for things such as the build platform, version code, etc. (again, documented in detail on the docs site).
Building a project takes a solid few minutes, but there are potentially ways it could be improved by caching certain files.
Once the project is built, I am able to send it to a remote Ubuntu server using the Copy via SSH action that I worked with previously.
To do all this, I worked with a test repo that I made myself. However, GitHub apparently has some sort of method to share my workflow with the entire RutgersGRID organization so that it can be centrally maintained and used in future projects. There are certainly potential improvements to be made, but this is a very promising start.