terraspace_ci_circleci 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88aa7a619627c1ffc00c3be9eb25f1ed52aef51113d614fd2a7a25537aa78f03
4
- data.tar.gz: 24d73984a44ce20c180dde3ea7c0deccd00c2ae9ade255595a8a040bc42cdaad
3
+ metadata.gz: 31ccc3812202bf94460a70d65ef3c01b94056a577b56bd333856ba52975160b8
4
+ data.tar.gz: 9465d2b5d5673076578cf5bc02aa934638450911894558686d074ecf42165c10
5
5
  SHA512:
6
- metadata.gz: 748151767f81f5fe0df19ebebb01f0855cb4aebdf33922dde3e8e106188cfffabe0df241c561d1a111ff9fb17a1fb0309fc4a31b0a93344ee171b3b9aa4605ea
7
- data.tar.gz: aa01e0580f0e66e274cd9f57f882aa626daf42a1b0dc503031c2ed4c3d8311979eb19789c98e78103c8d5289d8fc1efdc8f8898c00898af61a9def62f29d2276
6
+ metadata.gz: 697e26dbafd89e87eeab8a3c24c0a094d0eaa2a4d32aa48567297a86cbbdf76a6aff45fae0a5c65b1c04d2b389e1240b9f7e0b351648fcd4b067fc347eac3f6c
7
+ data.tar.gz: 32999d6109cc1ce0feb9abf275b2ff478676a48a5fb0c4780a562cca972e06931a0d07fa84456b98b6b5b9c80c17464ba03ca4d243a3f64590dc05fb042516c7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0] - 2022-07-14
4
+ - [#1](https://github.com/boltops-tools/terraspace_ci_circleci/pull/1) template: simple push and branch workflows
5
+
3
6
  ## [0.1.0] - 2022-07-14
4
7
 
5
8
  - Initial release
@@ -9,37 +9,59 @@ parameters:
9
9
  default: false
10
10
 
11
11
  jobs:
12
- # Manually triggered: TS_ENV=prod
13
- prod_plan:
12
+ dev_plan:
14
13
  docker:
15
14
  - image: cimg/ruby:3.1.0
16
15
  environment: *common_env_vars
17
16
  steps:
18
17
  - checkout
19
18
  - run: .circleci/bin/install
20
- - run: TS_ENV=prod terraspace plan demo
21
- prod_up:
19
+ - run: terraspace plan demo
20
+ dev_up:
22
21
  docker:
23
22
  - image: cimg/ruby:3.1.0
24
23
  environment: *common_env_vars
25
24
  steps:
26
25
  - checkout
27
26
  - run: .circleci/bin/install
28
- - run: TS_ENV=prod terraspace up demo -y
29
-
30
- # On PR: TS_ENV=dev terraspace plan
31
- # On push: TS_ENV=dev terraspace up - checks a specific branch only
32
- dev_plan_or_up:
27
+ - run: terraspace up demo -y
28
+ # Manually triggered: TS_ENV=prod
29
+ prod_plan:
30
+ docker:
31
+ - image: cimg/ruby:3.1.0
32
+ environment: *common_env_vars
33
+ steps:
34
+ - checkout
35
+ - run: .circleci/bin/install
36
+ - run: TS_ENV=prod terraspace plan demo
37
+ prod_up:
33
38
  docker:
34
39
  - image: cimg/ruby:3.1.0
35
40
  environment: *common_env_vars
36
41
  steps:
37
42
  - checkout
38
43
  - run: .circleci/bin/install
39
- - run: .circleci/bin/terraspace-plan-or-up.sh demo # depends if PR
44
+ - run: TS_ENV=prod terraspace up demo -y
40
45
 
41
46
  workflows:
42
- prod_plan_then_up_with_approval:
47
+ # use different dev_plan and dev_up workflows so it shows up on the CircleCI dashboard
48
+ dev_plan:
49
+ when:
50
+ not: << pipeline.parameters.manual >>
51
+ jobs:
52
+ - dev_plan:
53
+ filters:
54
+ branches:
55
+ ignore: main
56
+ dev_up:
57
+ when:
58
+ not: << pipeline.parameters.manual >>
59
+ jobs:
60
+ - dev_up:
61
+ filters:
62
+ branches:
63
+ only: main
64
+ prod_with_approval:
43
65
  when: << pipeline.parameters.manual >>
44
66
  jobs:
45
67
  - prod_plan
@@ -50,8 +72,3 @@ workflows:
50
72
  - prod_up:
51
73
  requires:
52
74
  - hold
53
- dev_plan_or_up:
54
- when:
55
- not: << pipeline.parameters.manual >>
56
- jobs:
57
- - dev_plan_or_up
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TerraspaceCiCircleci
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -9,6 +9,7 @@ module TerraspaceCiCircleci
9
9
  class Error < StandardError; end
10
10
  end
11
11
 
12
+ require "terraspace"
12
13
  Terraspace::Cloud::Ci.register(
13
14
  name: "circleci",
14
15
  env_key: "CIRCLECI",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraspace_ci_circleci
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen
@@ -39,7 +39,6 @@ files:
39
39
  - README.md
40
40
  - Rakefile
41
41
  - lib/template/.circleci/bin/install
42
- - lib/template/.circleci/bin/terraspace-plan-or-up.sh
43
42
  - lib/template/.circleci/config.yml
44
43
  - lib/terraspace_ci_circleci.rb
45
44
  - lib/terraspace_ci_circleci/autoloader.rb
@@ -1,25 +0,0 @@
1
- #!/bin/bash
2
- set -ex
3
-
4
- # Looks like only able to conditionally decide with CIRCLE_PULL_REQUEST and CIRCLE_BRANCH
5
- # at runtime instead of circleci evaluation time for the workflow we're trying to achieve.
6
- # So will "cancel" workflows that don't really want to run we can see this with the status visually.
7
- #
8
- if [ -n "$CIRCLE_PULL_REQUEST" ]; then
9
- exec terraspace plan "$@"
10
- else
11
- if [ "$CIRCLE_BRANCH" == "main" ]; then
12
- exec terraspace up "$@" -y
13
- else
14
- # cancel workflow and set status
15
- if [ -n "$CIRCLE_TOKEN" ] ; then
16
- # https://circleci.com/docs/api/v2/index.html#operation/cancelWorkflow
17
- curl --request POST \
18
- --header "Circle-Token: $CIRCLE_TOKEN" \
19
- https://circleci.com/api/v2/workflow/$CIRCLE_WORKFLOW_ID/cancel
20
- sleep 10 # seems to allow the curl request to cancel consistently
21
- fi
22
- # For correct Workflow Cancelled Status also. Correct status only if also cancel via the API
23
- circleci step halt
24
- fi
25
- fi