renuo-cli 4.8.0 → 4.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/renuo/cli/app/check_deploio_status.rb +91 -0
- data/lib/renuo/cli/app/github_pull_request_creator.rb +1 -0
- data/lib/renuo/cli/app/secrets_initializer.rb +17 -0
- data/lib/renuo/cli/app/templates/semaphore/semaphore-deploy.yml.erb +12 -6
- data/lib/renuo/cli/version.rb +1 -1
- data/lib/renuo/cli.rb +16 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '04291b4eb0fc68e50a9f32892ffb919a09e3882392c5e19d59142ddfad4bab70'
|
4
|
+
data.tar.gz: 79daac8a6706f7a4b6b35cb99ee557957a46e90372e74209bf3f981703caea5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 255b29d9038800e6a3a617ca7008bd02bfbf674fbfad0e7e25d2af37cb4201d5dd7f7832762d8e257ac592f0a052c64204fa45e5be0782ed301edcba1f06f7c8
|
7
|
+
data.tar.gz: 07f1ed5bac3218021d690754ec444496bee612b2f7e09f0ad7ab170d340901cdfc707fce50666f23a5c217669562315cc6ade29837c248d9989e9eb6055cb745
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "open3"
|
4
|
+
require "psych"
|
5
|
+
|
6
|
+
# :nocov:
|
7
|
+
class CheckDeploioStatus
|
8
|
+
TIMEOUT_IN_SECONDS = 600
|
9
|
+
INTERVAL_IN_SECONDS = 30
|
10
|
+
|
11
|
+
APP_NAME = ENV.fetch "DEPLOIO_APP_NAME", nil
|
12
|
+
PROJECT = ENV.fetch "DEPLOIO_PROJECT", nil
|
13
|
+
REVISION = `git rev-parse HEAD`.strip
|
14
|
+
|
15
|
+
def run
|
16
|
+
puts "(1/2) Checking build status for revision #{REVISION}..."
|
17
|
+
poll "build"
|
18
|
+
abort "build check timed out after #{TIMEOUT_IN_SECONDS} seconds" if build.nil?
|
19
|
+
|
20
|
+
puts "(2/2) Checking release status for build #{build_name}..."
|
21
|
+
poll "release"
|
22
|
+
abort "release check timed out after #{TIMEOUT_IN_SECONDS} seconds" if release.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def system!(cmd)
|
28
|
+
abort unless system cmd
|
29
|
+
end
|
30
|
+
|
31
|
+
def fetch(type)
|
32
|
+
command = "nctl get #{type} -a #{APP_NAME} -p #{PROJECT} -o yaml"
|
33
|
+
stdout, stderr, status = Open3.capture3 command
|
34
|
+
|
35
|
+
abort "error fetching #{type} information: #{stderr}" unless status.success?
|
36
|
+
Psych.load_stream stdout
|
37
|
+
end
|
38
|
+
|
39
|
+
def build
|
40
|
+
@build ||= fetch("builds").find do |build|
|
41
|
+
build.dig "spec", "forProvider", "sourceConfig", "git", "revision" == REVISION
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def build_name
|
46
|
+
@build_name ||= build.dig "metadata", "name"
|
47
|
+
end
|
48
|
+
|
49
|
+
def build_status
|
50
|
+
build.dig "status", "atProvider", "buildStatus"
|
51
|
+
end
|
52
|
+
|
53
|
+
def release
|
54
|
+
@release ||= fetch("releases").find do |release|
|
55
|
+
release.dig "spec", "forProvider", "build", build_name == "name"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def release_status
|
60
|
+
release.dig "status", "atProvider", "releaseStatus"
|
61
|
+
end
|
62
|
+
|
63
|
+
def succeeded?(status, type)
|
64
|
+
case status
|
65
|
+
when "available", "success"
|
66
|
+
puts "#{type} succeeded"
|
67
|
+
true
|
68
|
+
when "error", "failed"
|
69
|
+
abort "#{type} failed"
|
70
|
+
else
|
71
|
+
puts "#{type} status is #{status}, waiting..."
|
72
|
+
instance_variable_set :"@#{type}", nil
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def poll(type)
|
77
|
+
elapsed = 0
|
78
|
+
|
79
|
+
while elapsed < TIMEOUT_IN_SECONDS
|
80
|
+
if send type
|
81
|
+
break if succeeded? send :"#{type}_status", type
|
82
|
+
else
|
83
|
+
puts "no matching #{type} found, waiting..."
|
84
|
+
end
|
85
|
+
|
86
|
+
sleep INTERVAL_IN_SECONDS
|
87
|
+
elapsed += INTERVAL_IN_SECONDS
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
# :nocov:
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
require "fileutils"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
class SecretsInitializer
|
8
|
+
def self.run(private_vault_link)
|
9
|
+
abort("Config file #{SecretsFetcher::CONFIG_FILE} already exists.") if File.exist?(SecretsFetcher::CONFIG_FILE)
|
10
|
+
|
11
|
+
File.write(SecretsFetcher::CONFIG_FILE, generate_config_file(private_vault_link))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.generate_config_file(private_vault_link)
|
15
|
+
{ "items" => [{ "private_link" => private_vault_link, "files" => [], "env_variables" => [] }] }.to_yaml
|
16
|
+
end
|
17
|
+
end
|
@@ -9,14 +9,20 @@ blocks:
|
|
9
9
|
- name: <%= environment %>-deploy
|
10
10
|
task:
|
11
11
|
secrets:
|
12
|
-
- name:
|
12
|
+
- name: <%= project_name %>
|
13
13
|
env_vars:
|
14
|
-
- name:
|
15
|
-
value:
|
14
|
+
- name: DEPLOIO_PROJECT
|
15
|
+
value: renuo-<%= project_name %>
|
16
|
+
- name: DEPLOIO_APP_NAME
|
17
|
+
value: <%= environment %>
|
16
18
|
jobs:
|
17
19
|
- name: <%= environment %>-deploy
|
18
20
|
commands:
|
19
21
|
- checkout --use-cache
|
20
|
-
-
|
21
|
-
-
|
22
|
-
-
|
22
|
+
- echo 'deb [trusted=yes] https://repo.nine.ch/deb/ /' | sudo tee /etc/apt/sources.list.d/repo.nine.ch.list
|
23
|
+
- sudo apt-get -qq update
|
24
|
+
- sudo apt-get -qq install -y nctl
|
25
|
+
- nctl auth login --api-token=$API_TOKEN --organization=renuo
|
26
|
+
- nctl update app $DEPLOIO_APP_NAME -p $DEPLOIO_PROJECT --build-env="RUBY_VERSION=$(cat .ruby-version)" --git-revision=$(git rev-parse HEAD) --skip-repo-access-check
|
27
|
+
- gem i renuo-cli
|
28
|
+
- renuo check-deploio-status
|
data/lib/renuo/cli/version.rb
CHANGED
data/lib/renuo/cli.rb
CHANGED
@@ -29,7 +29,9 @@ require "renuo/cli/app/commit_leaderboard_stage"
|
|
29
29
|
require "renuo/cli/app/commit_leaderboard_sync"
|
30
30
|
require "renuo/cli/app/github_replace"
|
31
31
|
require "renuo/cli/app/github_pull_request_creator"
|
32
|
+
require "renuo/cli/app/secrets_initializer"
|
32
33
|
require "renuo/cli/app/secrets_fetcher"
|
34
|
+
require "renuo/cli/app/check_deploio_status"
|
33
35
|
require "highline"
|
34
36
|
|
35
37
|
def agree(question)
|
@@ -298,12 +300,25 @@ module Renuo
|
|
298
300
|
command "fetch-secrets" do |c|
|
299
301
|
c.syntax = "renuo fetch-secrets"
|
300
302
|
c.summary = "Fetches the needed secrets in a project from the renuo secrets store"
|
303
|
+
c.option "--init <private_vault_link>", String, "Initializes the renuo secrets store"
|
301
304
|
c.description = <<~DESCRIPTION
|
302
305
|
Run the command within a project folder to fetch the secrets from the renuo secrets store.
|
303
306
|
The bin/setup of the project might run this command for you.
|
304
307
|
DESCRIPTION
|
308
|
+
c.action do |_, opts|
|
309
|
+
if opts.init
|
310
|
+
SecretsInitializer.run(opts.init)
|
311
|
+
else
|
312
|
+
SecretsFetcher.new.run
|
313
|
+
end
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
command "check-deploio-status" do |c|
|
318
|
+
c.syntax = "renuo check-deploio-status"
|
319
|
+
c.summary = "Checks the build and release status of the deployment."
|
305
320
|
c.action do
|
306
|
-
|
321
|
+
CheckDeploioStatus.new.run
|
307
322
|
end
|
308
323
|
end
|
309
324
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: renuo-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Renuo AG
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-01-
|
10
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: activesupport
|
@@ -319,6 +319,7 @@ files:
|
|
319
319
|
- bin/setup
|
320
320
|
- config/1password-secrets.yml
|
321
321
|
- lib/renuo/cli.rb
|
322
|
+
- lib/renuo/cli/app/check_deploio_status.rb
|
322
323
|
- lib/renuo/cli/app/command_helper.rb
|
323
324
|
- lib/renuo/cli/app/commit_leaderboard_stage.rb
|
324
325
|
- lib/renuo/cli/app/commit_leaderboard_sync.rb
|
@@ -342,6 +343,7 @@ files:
|
|
342
343
|
- lib/renuo/cli/app/release_project.rb
|
343
344
|
- lib/renuo/cli/app/renuo_version.rb
|
344
345
|
- lib/renuo/cli/app/secrets_fetcher.rb
|
346
|
+
- lib/renuo/cli/app/secrets_initializer.rb
|
345
347
|
- lib/renuo/cli/app/services/cloudfront_config_service.rb
|
346
348
|
- lib/renuo/cli/app/services/markdown_parser_service.rb
|
347
349
|
- lib/renuo/cli/app/services/renuo_cli_config.rb
|