|
| 1 | +# AWS Examples |
| 2 | + |
| 3 | +Complete workflow examples for running Unity builds on AWS Fargate via Orchestrator. |
| 4 | + |
| 5 | +## Minimal AWS Build |
| 6 | + |
| 7 | +The simplest AWS workflow. Uses default CPU and memory. |
| 8 | + |
| 9 | +```yaml |
| 10 | +name: Build with Orchestrator (AWS) |
| 11 | + |
| 12 | +on: |
| 13 | + push: |
| 14 | + branches: [main] |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + with: |
| 22 | + lfs: true |
| 23 | + |
| 24 | + - name: Configure AWS Credentials |
| 25 | + uses: aws-actions/configure-aws-credentials@v4 |
| 26 | + with: |
| 27 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 28 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 29 | + aws-region: eu-west-2 |
| 30 | + |
| 31 | + - uses: game-ci/unity-builder@v4 |
| 32 | + with: |
| 33 | + providerStrategy: aws |
| 34 | + targetPlatform: StandaloneLinux64 |
| 35 | + gitPrivateToken: ${{ secrets.GITHUB_TOKEN }} |
| 36 | +``` |
| 37 | +
|
| 38 | +## Multi-Platform Matrix Build |
| 39 | +
|
| 40 | +Build for multiple platforms in parallel. Each platform runs as a separate Fargate task. |
| 41 | +
|
| 42 | +```yaml |
| 43 | +name: Orchestrator — AWS Multi-Platform |
| 44 | + |
| 45 | +on: |
| 46 | + push: |
| 47 | + branches: [main, develop] |
| 48 | + pull_request: |
| 49 | + branches: [main] |
| 50 | + |
| 51 | +jobs: |
| 52 | + build: |
| 53 | + name: Build (${{ matrix.targetPlatform }}) |
| 54 | + runs-on: ubuntu-latest |
| 55 | + strategy: |
| 56 | + fail-fast: false |
| 57 | + matrix: |
| 58 | + targetPlatform: |
| 59 | + - StandaloneLinux64 |
| 60 | + - StandaloneWindows64 |
| 61 | + - StandaloneOSX |
| 62 | + - iOS |
| 63 | + - Android |
| 64 | + - WebGL |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + with: |
| 68 | + lfs: true |
| 69 | + |
| 70 | + - name: Configure AWS Credentials |
| 71 | + uses: aws-actions/configure-aws-credentials@v4 |
| 72 | + with: |
| 73 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 74 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 75 | + aws-region: eu-west-2 |
| 76 | + |
| 77 | + - uses: game-ci/unity-builder@v4 |
| 78 | + id: build |
| 79 | + with: |
| 80 | + providerStrategy: aws |
| 81 | + targetPlatform: ${{ matrix.targetPlatform }} |
| 82 | + gitPrivateToken: ${{ secrets.GITHUB_TOKEN }} |
| 83 | + unityVersion: 2022.3.0f1 |
| 84 | + containerCpu: 2048 |
| 85 | + containerMemory: 8192 |
| 86 | + containerHookFiles: aws-s3-upload-build |
| 87 | + githubCheck: true |
| 88 | +``` |
| 89 | +
|
| 90 | +## Custom Resources and S3 Artifacts |
| 91 | +
|
| 92 | +Specify CPU/memory and export build artifacts to S3. |
| 93 | +
|
| 94 | +```yaml |
| 95 | +- uses: game-ci/unity-builder@v4 |
| 96 | + id: aws-build |
| 97 | + with: |
| 98 | + providerStrategy: aws |
| 99 | + versioning: None |
| 100 | + projectPath: path/to/your/project |
| 101 | + unityVersion: 2022.3.0f1 |
| 102 | + targetPlatform: ${{ matrix.targetPlatform }} |
| 103 | + gitPrivateToken: ${{ secrets.GITHUB_TOKEN }} |
| 104 | + containerCpu: 2048 |
| 105 | + containerMemory: 8192 |
| 106 | + # Export builds to S3: |
| 107 | + containerHookFiles: aws-s3-upload-build |
| 108 | +``` |
| 109 | +
|
| 110 | +### Valid CPU/Memory Combinations |
| 111 | +
|
| 112 | +AWS Fargate only accepts specific combinations (`1024 = 1 vCPU`, memory in MB): |
| 113 | + |
| 114 | +| CPU (`containerCpu`) | Memory (`containerMemory`) | |
| 115 | +| -------------------- | ---------------------------- | |
| 116 | +| `256` (0.25 vCPU) | `512`, `1024`, `2048` | |
| 117 | +| `512` (0.5 vCPU) | `1024` – `4096` | |
| 118 | +| `1024` (1 vCPU) | `2048` – `8192` | |
| 119 | +| `2048` (2 vCPU) | `4096` – `16384` | |
| 120 | +| `4096` (4 vCPU) | `8192` – `30720` | |
| 121 | + |
| 122 | +## Async Mode |
| 123 | + |
| 124 | +For long builds, use async mode so the GitHub Action returns immediately. Monitor via GitHub Checks. |
| 125 | + |
| 126 | +```yaml |
| 127 | +- uses: game-ci/unity-builder@v4 |
| 128 | + with: |
| 129 | + providerStrategy: aws |
| 130 | + targetPlatform: StandaloneLinux64 |
| 131 | + gitPrivateToken: ${{ secrets.GITHUB_TOKEN }} |
| 132 | + asyncOrchestrator: true |
| 133 | + githubCheck: true |
| 134 | +``` |
| 135 | + |
| 136 | +## Retained Workspaces |
| 137 | + |
| 138 | +Keep the entire project cached between builds for dramatically faster rebuilds. |
| 139 | + |
| 140 | +```yaml |
| 141 | +- uses: game-ci/unity-builder@v4 |
| 142 | + with: |
| 143 | + providerStrategy: aws |
| 144 | + targetPlatform: StandaloneLinux64 |
| 145 | + gitPrivateToken: ${{ secrets.GITHUB_TOKEN }} |
| 146 | + maxRetainedWorkspaces: 3 |
| 147 | + containerCpu: 2048 |
| 148 | + containerMemory: 8192 |
| 149 | +``` |
| 150 | + |
| 151 | +## S3 Upload + Steam Deploy |
| 152 | + |
| 153 | +Chain container hooks to export to S3 and deploy to Steam in one step. |
| 154 | + |
| 155 | +```yaml |
| 156 | +- uses: game-ci/unity-builder@v4 |
| 157 | + with: |
| 158 | + providerStrategy: aws |
| 159 | + targetPlatform: StandaloneLinux64 |
| 160 | + gitPrivateToken: ${{ secrets.GITHUB_TOKEN }} |
| 161 | + containerHookFiles: aws-s3-upload-build,steam-deploy-client |
| 162 | + env: |
| 163 | + STEAM_USERNAME: ${{ secrets.STEAM_USERNAME }} |
| 164 | + STEAM_PASSWORD: ${{ secrets.STEAM_PASSWORD }} |
| 165 | + STEAM_APPID: ${{ secrets.STEAM_APPID }} |
| 166 | +``` |
| 167 | + |
| 168 | +## Scheduled Garbage Collection |
| 169 | + |
| 170 | +Clean up stale CloudFormation stacks and Fargate tasks. |
| 171 | + |
| 172 | +```yaml |
| 173 | +name: Orchestrator — Garbage Collect |
| 174 | +
|
| 175 | +on: |
| 176 | + schedule: |
| 177 | + - cron: '0 4 * * *' # Daily at 4 AM UTC |
| 178 | +
|
| 179 | +jobs: |
| 180 | + cleanup: |
| 181 | + runs-on: ubuntu-latest |
| 182 | + steps: |
| 183 | + - uses: actions/checkout@v4 |
| 184 | +
|
| 185 | + - name: Configure AWS Credentials |
| 186 | + uses: aws-actions/configure-aws-credentials@v4 |
| 187 | + with: |
| 188 | + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} |
| 189 | + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |
| 190 | + aws-region: eu-west-2 |
| 191 | +
|
| 192 | + - uses: game-ci/unity-builder@v4 |
| 193 | + with: |
| 194 | + providerStrategy: aws |
| 195 | + mode: garbage-collect |
| 196 | + garbageMaxAge: 24 |
| 197 | + gitPrivateToken: ${{ secrets.GITHUB_TOKEN }} |
| 198 | +``` |
| 199 | + |
| 200 | +## CLI Usage |
| 201 | + |
| 202 | +Run AWS builds from the command line: |
| 203 | + |
| 204 | +```bash |
| 205 | +game-ci build \ |
| 206 | + --providerStrategy aws \ |
| 207 | + --projectPath /path/to/unity/project \ |
| 208 | + --targetPlatform StandaloneLinux64 \ |
| 209 | + --containerCpu 2048 \ |
| 210 | + --containerMemory 8192 |
| 211 | +``` |
| 212 | + |
| 213 | +List active AWS resources: |
| 214 | + |
| 215 | +```bash |
| 216 | +game-ci status --providerStrategy aws |
| 217 | +``` |
| 218 | + |
| 219 | +## Required Secrets |
| 220 | + |
| 221 | +| Secret | Description | |
| 222 | +| ----------------------- | ---------------------------------------------------------------- | |
| 223 | +| `AWS_ACCESS_KEY_ID` | IAM access key with ECS, CloudFormation, S3, Kinesis, CloudWatch | |
| 224 | +| `AWS_SECRET_ACCESS_KEY` | IAM secret key | |
| 225 | + |
| 226 | +## Next Steps |
| 227 | + |
| 228 | +- [AWS Provider Reference](../providers/aws) — architecture, parameters, and setup |
| 229 | +- [Container Hooks](../advanced-topics/hooks/built-in-hooks) — S3, rclone, Steam hooks |
| 230 | +- [Garbage Collection](../advanced-topics/garbage-collection) — automated cleanup |
| 231 | +- [API Reference](../api-reference) — full parameter list |
0 commit comments