Skip to content

Commit

Permalink
cloud_init: Add config and setup to run github actions runners
Browse files Browse the repository at this point in the history
Co-authored-by: Peter Wall <[email protected]>
  • Loading branch information
joakimk and p-wall committed Dec 2, 2024
1 parent eb567fa commit a813eb0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
17 changes: 11 additions & 6 deletions app/controllers/api/cloud_inits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def show
lock_passwd: false,
chpasswd: { expire: false },
sudo: "ALL=(ALL) NOPASSWD:ALL",
shell: "/bin/bash"
shell: "/bin/bash",
}
],
disable_root: true,
Expand All @@ -21,16 +21,21 @@ def show
package_upgrade: true,
write_files: [
{
path: "/etc/motd",
content: "Hello there."
}
path: "/etc/environment",
content: %{
RUNNER_CFG_PAT=#{App.github_actions_runner_cfg_pat}
},
append: true,
},
],
runcmd: [
"while read -r env; do export \"$env\"; done < /etc/environment",
"systemctl stop sshd",
"systemctl disable sshd",
"curl https://maintenance.auctionet.dev/it-ran",
"reboot"
]
"curl -s https://raw.githubusercontent.com/actions/runner/main/scripts/create-latest-svc.sh | bash -s #{App.github_actions_runner_scope}",
"reboot",
],
}

yaml = "#cloud-config\n" +
Expand Down
16 changes: 16 additions & 0 deletions config/initializers/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,22 @@ def self.api_token
end
end

def self.github_actions_runner_cfg_pat
if Rails.env.test? || Rails.env.development?
"test-runner-cfg-pat"
else
ENV.fetch("CLOUD_INIT_GITHUB_ACTIONS_RUNNER_CFG_PAT")
end
end

def self.github_actions_runner_scope
if Rails.env.test? || Rails.env.development?
"test-runner-scope"
else
ENV.fetch("CLOUD_INIT_GITHUB_ACTIONS_RUNNER_SCOPE")
end
end

def self.revisions_to_keep
(ENV["REVISIONS_TO_KEEP"] || 500).to_i
end
Expand Down

0 comments on commit a813eb0

Please sign in to comment.