Cleanup remote builder github workflows

pull/310/head
Frostebite 2021-09-22 20:15:41 +01:00
parent 4d8baee3a4
commit 1f12f8c5cc
6 changed files with 135 additions and 22 deletions

View File

@ -1,4 +1,4 @@
name: AWS Fargate name: Remote Build AWS Fargate
on: on:
push: { branches: [main, aws, remote-builder/unified-providers] } push: { branches: [main, aws, remote-builder/unified-providers] }

View File

@ -0,0 +1,70 @@
name: Remote Build AWS Fargate Custom
on:
push: { branches: [main, aws, remote-builder/unified-providers] }
env:
AWS_REGION: 'eu-west-1'
jobs:
buildForAllPlatforms:
name: AWS Fargate Build
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
projectPath:
- test-project
unityVersion:
# - 2019.2.11f1
- 2019.3.15f1
targetPlatform:
#- StandaloneOSX # Build a macOS standalone (Intel 64-bit).
#- StandaloneWindows64 # Build a Windows 64-bit standalone.
- StandaloneLinux64 # Build a Linux 64-bit standalone.
#- iOS # Build an iOS player.
#- Android # Build an Android .apk.
#- WebGL # WebGL.
# - StandaloneWindows # Build a Windows standalone.
# - WSAPlayer # Build an Windows Store Apps player.
# - PS4 # Build a PS4 Standalone.
# - XboxOne # Build a Xbox One Standalone.
# - tvOS # Build to Apple's tvOS platform.
# - Switch # Build a Nintendo Switch player
# steps
steps:
- name: Checkout (default)
uses: actions/checkout@v2
if: github.event.event_type != 'pull_request_target'
with:
lfs: true
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: eu-west-2
- uses: ./
id: aws-fargate-unity-build
env:
UNITY_LICENSE: ${{ secrets.UNITY_LICENSE }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: eu-west-2
CloudRunnerBranch: remote-builder/unified-providers
DEBUG: true
with:
cloudRunnerCluster: aws
projectPath: ${{ matrix.projectPath }}
unityVersion: ${{ matrix.unityVersion }}
targetPlatform: ${{ matrix.targetPlatform }}
githubToken: ${{ secrets.GITHUB_TOKEN }}
awsBaseStackName: game-ci-stack
customBuildSteps: >-
- name: 'step 1'
image: 'alpine'
commands: ['mkdir actions-runner && cd actions-runner && curl -O -L https://github.com/actions/runner/releases/download/v2.283.1/actions-runner-linux-x64-2.283.1.tar.gz && tar xzf ./actions-runner-linux-x64-2.283.1.tar.gz']
secrets:
- name: 'testCustomSecret'
value: 'VALUEXXX'

View File

@ -1,4 +1,4 @@
name: Kubernetes GKE + Autopilot name: Remote Build Kubernetes GKE + Autopilot
on: on:
push: { branches: [remote-builder/k8s, remote-builder/unified-providers] } push: { branches: [remote-builder/k8s, remote-builder/unified-providers] }

54
dist/index.js vendored
View File

@ -403,25 +403,25 @@ class AWSBuildEnvironment {
}); });
} }
getParameterTemplate(p1) { getParameterTemplate(p1) {
return ` return `
${p1}: ${p1}:
Type: String Type: String
Default: '' Default: ''
`; `;
} }
getSecretTemplate(p1) { getSecretTemplate(p1) {
return ` return `
${p1}Secret: ${p1}Secret:
Type: AWS::SecretsManager::Secret Type: AWS::SecretsManager::Secret
Properties: Properties:
Name: !Join [ "", [ '${p1}', !Ref BUILDID ] ] Name: !Join [ "", [ '${p1}', !Ref BUILDID ] ]
SecretString: !Ref ${p1} SecretString: !Ref ${p1}
`; `;
} }
getSecretDefinitionTemplate(p1, p2) { getSecretDefinitionTemplate(p1, p2) {
return ` return `
- Name: '${p1}' - Name: '${p1}'
ValueFrom: !Ref ${p2}Secret ValueFrom: !Ref ${p2}Secret
`; `;
} }
insertAtTemplate(template, insertionKey, insertion) { insertAtTemplate(template, insertionKey, insertion) {
@ -432,8 +432,8 @@ class AWSBuildEnvironment {
setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) { setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const logGuid = nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 9)(); const logGuid = nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 9)();
commands[1] += ` commands[1] += `
echo "${logGuid}" echo "${logGuid}"
`; `;
yield this.setupBaseStack(CF); yield this.setupBaseStack(CF);
const taskDefStackName = `${this.baseStackName}-${buildGuid}`; const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
@ -1203,7 +1203,7 @@ class CloudRunner {
} }
static runMainJob(baseImage) { static runMainJob(baseImage) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
if (this.buildParams.customBuildSteps !== '') { if (this.buildParams.customBuildSteps === '') {
cloud_runner_logger_1.default.log(`Cloud Runner is running in standard build automation mode`); cloud_runner_logger_1.default.log(`Cloud Runner is running in standard build automation mode`);
yield CloudRunner.standardBuildAutomation(baseImage); yield CloudRunner.standardBuildAutomation(baseImage);
} }
@ -1242,6 +1242,24 @@ class CloudRunner {
} }
}); });
} }
static runEphemeralRegistrationJob(buildSteps) {
return __awaiter(this, void 0, void 0, function* () {
buildSteps = yaml_1.default.parse(buildSteps);
for (const step of buildSteps) {
const stepSecrets = step.secrets.map((x) => {
const secret = {
ParameterKey: x.name,
EnvironmentVariable: x.name,
ParameterValue: x.value,
};
return secret;
});
yield this.CloudRunnerProviderPlatform.runBuildTask(this.buildGuid, step['image'], [
'mkdir actions-runner && cd actions-runner && curl -O -L https://github.com/actions/runner/releases/download/v2.283.1/actions-runner-linux-x64-2.283.1.tar.gz && tar xzf ./actions-runner-linux-x64-2.283.1.tar.gz && ls',
], `/${buildVolumeFolder}`, `/${buildVolumeFolder}`, this.defaultGitShaEnvironmentVariable, [...this.defaultSecrets, ...stepSecrets]);
}
});
}
static setupStep() { static setupStep() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
cloud_runner_logger_1.default.log('Starting step 1/4 clone and restore cache)'); cloud_runner_logger_1.default.log('Starting step 1/4 clone and restore cache)');
@ -1624,8 +1642,8 @@ class KubernetesJobSpecFactory {
command: [ command: [
'bin/bash', 'bin/bash',
'-c', '-c',
`cd /data/builder/action/steps; `cd /data/builder/action/steps;
chmod +x /return_license.sh; chmod +x /return_license.sh;
/return_license.sh;`, /return_license.sh;`,
], ],
}, },

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -246,7 +246,7 @@ class CloudRunner {
} }
private static async runMainJob(baseImage: any) { private static async runMainJob(baseImage: any) {
if (this.buildParams.customBuildSteps !== '') { if (this.buildParams.customBuildSteps === '') {
CloudRunnerLogger.log(`Cloud Runner is running in standard build automation mode`); CloudRunnerLogger.log(`Cloud Runner is running in standard build automation mode`);
await CloudRunner.standardBuildAutomation(baseImage); await CloudRunner.standardBuildAutomation(baseImage);
} else { } else {
@ -290,6 +290,31 @@ class CloudRunner {
} }
} }
private static async runEphemeralRegistrationJob(buildSteps) {
buildSteps = YAML.parse(buildSteps);
for (const step of buildSteps) {
const stepSecrets: CloudRunnerSecret[] = step.secrets.map((x) => {
const secret: CloudRunnerSecret = {
ParameterKey: x.name,
EnvironmentVariable: x.name,
ParameterValue: x.value,
};
return secret;
});
await this.CloudRunnerProviderPlatform.runBuildTask(
this.buildGuid,
step['image'],
[
'mkdir actions-runner && cd actions-runner && curl -O -L https://github.com/actions/runner/releases/download/v2.283.1/actions-runner-linux-x64-2.283.1.tar.gz && tar xzf ./actions-runner-linux-x64-2.283.1.tar.gz && ls',
],
`/${buildVolumeFolder}`,
`/${buildVolumeFolder}`,
this.defaultGitShaEnvironmentVariable,
[...this.defaultSecrets, ...stepSecrets],
);
}
}
private static async setupStep() { private static async setupStep() {
CloudRunnerLogger.log('Starting step 1/4 clone and restore cache)'); CloudRunnerLogger.log('Starting step 1/4 clone and restore cache)');
await this.CloudRunnerProviderPlatform.runBuildTask( await this.CloudRunnerProviderPlatform.runBuildTask(