-
Notifications
You must be signed in to change notification settings - Fork 18
116 lines (96 loc) · 3.57 KB
/
validate.yaml
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
106
107
108
109
110
111
112
113
114
115
116
name: Validate Changes
on:
pull_request:
types: [opened, synchronize, closed, reopened]
paths:
- '.github/workflows/validate.yaml'
- 'lib/**'
- 'bin/**'
- 'examples/maildog.config.json'
- 'pacakge.json'
- 'package-lock.json'
- 'tsconfig.json'
- 'cdk.json'
branches:
- main
jobs:
validate:
name: Deploy changes
runs-on: ubuntu-latest
if: ${{ github.actor == github.repository_owner && github.event.action != 'closed' }}
environment: Test
steps:
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-npm-
${{ runner.OS }}-
- name: Install dependencies
run: npm ci
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Copy example config
run: cp ./examples/maildog.config.json maildog.config.json
- name: Deploy the CDK toolkit stack
run: npx cdk bootstrap
- name: Deploy maildog
run: npx cdk deploy --require-approval never
env:
ENVIRONMENT_NAME: ${{ env.GITHUB_HEAD_REF_SLUG_URL }}
teardown:
name: Destroy changes
runs-on: ubuntu-latest
if: ${{ github.actor == github.repository_owner && github.event.action == 'closed' }}
environment: Test
steps:
- name: Set up Node
uses: actions/setup-node@v1
with:
node-version: 14.x
- name: Checkout code
uses: actions/checkout@v2
- name: Cache dependencies
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.OS }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.OS }}-npm-
${{ runner.OS }}-
- name: Install dependencies
run: npm ci
- name: Inject slug/short variables
uses: rlespinasse/[email protected]
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Copy example config
run: cp ./examples/maildog.config.json maildog.config.json
- name: Deactivate receipt rule set
run: aws ses set-active-receipt-rule-set
- name: Destroy stack
run: npx cdk destroy --force
env:
ENVIRONMENT_NAME: ${{ env.GITHUB_HEAD_REF_SLUG_URL }}
- name: Remove bucket and its content
run: aws s3 rb s3://$(aws s3api list-buckets --query "Buckets[?starts_with(Name, 'maildog-${{ env.GITHUB_HEAD_REF_SLUG_URL }}-')].Name" --output text) --force
- name: Clear log groups from Lambda functions
run: aws logs describe-log-groups --log-group-name-prefix "/aws/lambda/MailDog-${{ env.GITHUB_HEAD_REF_SLUG_URL }}-" --query "logGroups[].logGroupName" --output text | xargs -I {} -n 1 aws logs delete-log-group --log-group-name {}