Skip to content

Commit

Permalink
add ssh key to avoid emails
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticroentgen committed Apr 15, 2024
1 parent 14d221c commit 863bb90
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CloudController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Text.Json;
using HetznerCloudApi;
using HetznerCloudApi.Object.ServerType;
using HetznerCloudApi.Object.SshKey;
using HetznerCloudApi.Object.Universal;
using Prometheus;
using RandomFriendlyNameGenerator;
Expand Down Expand Up @@ -63,6 +64,10 @@ public async Task<string> CreateNewRunner(string arch, string size, string runne
// Grab server type
List<ServerType> srvTypes = await _client.ServerType.Get();
long? srvType = srvTypes.FirstOrDefault(x => x.Name == vmSize)?.Id;

// Grab SSH keys
List<SshKey> sshKeys = await _client.SshKey.Get();
List<long> srvKeys = sshKeys.Select(x => x.Id).ToList();

// Create new server
string runnerVersion = "2.315.0";
Expand All @@ -76,7 +81,7 @@ public async Task<string> CreateNewRunner(string arch, string size, string runne
.AppendLine($" - [ sh, -xc, 'cd /opt/actions-runner && RUNNER_ALLOW_RUNASROOT=true ./config.sh --url https://github.com/{orgName} --token {runnerToken} --ephemeral --disableupdate --labels {size} && RUNNER_ALLOW_RUNASROOT=true ./run.sh ']")
.ToString();
_logger.LogInformation($"Launching VM {name}");
var newSrv = await _client.Server.Create(eDataCenter.nbg1, imageId.Value, name, srvType.Value, userData: cloudInitcontent);
var newSrv = await _client.Server.Create(eDataCenter.nbg1, imageId.Value, name, srvType.Value, userData: cloudInitcontent, sshKeysIds: srvKeys);
_activeRunners.Add(new Machine
{
Id = newSrv.Id,
Expand Down

0 comments on commit 863bb90

Please sign in to comment.