-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcircleci.example.yml
More file actions
59 lines (53 loc) · 1.73 KB
/
Copy pathcircleci.example.yml
File metadata and controls
59 lines (53 loc) · 1.73 KB
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
# Example CircleCI config.
#
# Wire the deploy job onto every non-main branch and the teardown onto closed
# PRs. Make sure the role you assume has permission to:
# - launch / terminate EC2 instances
# - create / update Route53 records in your hosted zone
# - read/write the S3 bucket from PREVIEW_S3_BUCKET
#
# Required context / project env vars:
# PREVIEW_SSH_PRIVATE_KEY (base64-encoded SSH private key)
# PREVIEW_KEY_NAME (EC2 key pair name; or set in preview.config.sh)
# GITHUB_TOKEN (optional, for PR label gating + PR comments)
# ...any secrets listed in PREVIEW_FORWARD_ENV
version: 2.1
orbs:
aws-cli: circleci/aws-cli@5.4.0
jobs:
deploy_preview:
docker:
- image: cimg/aws:2025.01
resource_class: small
steps:
- checkout
- aws-cli/setup:
profile_name: default
role_arn: arn:aws:iam::<AWS_ACCOUNT_ID>:role/circleci
- run:
name: Deploy preview environment
no_output_timeout: 30m
command: bash scripts/deploy.sh "<< pipeline.git.branch >>"
teardown_preview:
docker:
- image: cimg/aws:2025.01
resource_class: small
steps:
- checkout
- aws-cli/setup:
profile_name: default
role_arn: arn:aws:iam::<AWS_ACCOUNT_ID>:role/circleci
- run:
name: Teardown preview environment
command: bash scripts/teardown.sh "<< pipeline.event.github.pull_request.head.ref >>"
workflows:
deploy_preview_environment:
jobs:
- deploy_preview:
filters:
branches:
ignore: main
teardown_preview_environment:
when: pipeline.event.name == "pull_request" and pipeline.event.action == "closed"
jobs:
- teardown_preview