-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.yml
106 lines (105 loc) · 2.88 KB
/
config.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
default-machine: &default-machine
machine:
image: ubuntu-2204:current
docker_layer_caching: true
resource_class: arm.large
version: 2.1
orbs:
aws-cli: circleci/[email protected]
parameters:
workflow:
type: enum
default: test
description: The workflow to trigger.
enum: [test, deploy]
commands:
devcontainer-install:
steps:
- run: npm install -g @devcontainers/cli
devcontainer-build:
steps:
- run: devcontainer build --workspace-folder .
devcontainer-up:
steps:
- run: devcontainer up --workspace-folder .
- run: devcontainer run-user-commands --workspace-folder .
devcontainer-run:
parameters:
cmd: { type: string }
args: { type: string, default: "" }
options: { type: string, default: "" }
steps:
- attach_workspace:
at: .
- run: |
if [ -f aws.env ]; then
cat aws.env >> "$BASH_ENV"
fi
- run: >
devcontainer exec
--workspace-folder .
<< parameters.options >>
<< parameters.cmd >>
<< parameters.args >>
jobs:
devcontainer:
<<: *default-machine
steps:
- checkout
- devcontainer-install
- devcontainer-build
aws-oidc:
executor: aws-cli/default
steps:
- aws-cli/setup:
role-arn: $OIDC_ROLE_ARN
role-session-name: circleci
session-duration: '900'
- run:
name: Store Env Variables
command: |
echo "export AWS_ACCESS_KEY_ID=\"${AWS_ACCESS_KEY_ID}\"" > aws.env
echo "export AWS_SECRET_ACCESS_KEY=\"${AWS_SECRET_ACCESS_KEY}\"" >> aws.env
echo "export AWS_SESSION_TOKEN=\"${AWS_SESSION_TOKEN}\"" >> aws.env
- persist_to_workspace:
root: .
paths: [ aws.env ]
test-job:
<<: *default-machine
steps:
- checkout
- devcontainer-install
- devcontainer-up
- devcontainer-run: { cmd: ./bin/setup }
- devcontainer-run: { cmd: ./bin/test }
deploy-job:
<<: *default-machine
steps:
- checkout
- devcontainer-install
- devcontainer-up
- devcontainer-run:
options: >-
--remote-env AWS_REGION=us-east-1
--remote-env AWS_DEFAULT_REGION=us-east-1
--remote-env AWS_ACCESS_KEY_ID=$AWS_ACCESS_KEY_ID
--remote-env AWS_SECRET_ACCESS_KEY=$AWS_SECRET_ACCESS_KEY
--remote-env AWS_SESSION_TOKEN=$AWS_SESSION_TOKEN
cmd: |
./bin/deploy
workflows:
test:
when: { equal: [ test, << pipeline.parameters.workflow >> ] }
jobs:
- devcontainer
- test-job:
requires: [devcontainer]
deploy:
# when: { equal: [ deploy, << pipeline.parameters.workflow >> ] }
jobs:
- devcontainer
- aws-oidc:
context: org-global
requires: [devcontainer]
- deploy-job:
requires: [aws-oidc]