Module: Afterlife::Deploy

Defined in:
lib/afterlife/deploy.rb,
lib/afterlife/deploy/cli.rb,
lib/afterlife/deploy/deployment.rb,
lib/afterlife/deploy/cdn_deployment.rb,
lib/afterlife/deploy/custom_deployment.rb,
lib/afterlife/deploy/kubernetes_deployment.rb,
lib/afterlife/deploy/cdn_stenciljs_deployment.rb

Defined Under Namespace

Classes: CdnDeployment, CdnStenciljsDeployment, Cli, CustomDeployment, Deployment, KubernetesDeployment

Constant Summary collapse

DEPLOYMENTS =
{
  cdn: 'CdnDeployment',
  cdn_stenciljs: 'CdnStenciljsDeployment',
  custom: 'CustomDeployment',
  kubernetes: 'KubernetesDeployment',
}.freeze

Class Method Summary collapse

Class Method Details

.call(stage, options) {|deployment| ... } ⇒ Object

Yields:

  • (deployment)


14
15
16
17
18
19
20
21
# File 'lib/afterlife/deploy.rb', line 14

def call(stage, options)
  deployment = klass.new(options)
  Afterlife.current_stage = stage
  fill_env
  deployment.setup
  yield deployment
  deployment
end

.current_typeObject



30
31
32
33
34
# File 'lib/afterlife/deploy.rb', line 30

def current_type
  Afterlife.current_repo.conf.dig(:deploy, :type).tap do |result|
    fail Error, 'deploy.type must be defined if you want to deploy with Afterlife' unless result
  end
end

.fill_envObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/afterlife/deploy.rb', line 36

def fill_env
  # in nested deployments we need the current definition, not the parent's
  Afterlife.current_repo.env.set!(
    'DIST_PATH' => Afterlife.current_repo.dist_path.to_s,
    'CURRENT_BRANCH' => Afterlife.current_repo.current_branch,
    'AFTERLIFE_STAGE' => Afterlife.current_stage.name,
  )
  # IN CI we dont need an AWS_PROFILE and setting it causes aws s3 sync to fail
  Afterlife.current_repo.env.set!('AWS_PROFILE' => Afterlife.current_stage.profile) unless ENV['CI']
end

.klassObject



23
24
25
26
27
28
# File 'lib/afterlife/deploy.rb', line 23

def klass
  klass = DEPLOYMENTS[current_type.gsub('-', '_').to_sym]
  fail Error, "deployment type '#{current_type}' is invalid" unless klass

  const_get(klass)
end