Skip to content

Commit e173a63

Browse files
committed
test: ci deploy
1 parent 88ec191 commit e173a63

18 files changed

+9580
-1324
lines changed

.github/workflows/deploy.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: IpLocate Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
env:
9+
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
10+
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
11+
TF_VAR_geoip_account_id: ${{ secrets.TF_VAR_GEOIP_ACCOUNT_ID }}
12+
TF_VAR_geoip_license_key: ${{ secrets.TF_VAR_GEOIP_LICENSE_KEY }}
13+
TF_VAR_state_bucket: ${{ secrets.TF_VAR_STATE_BUCKET }}
14+
15+
jobs:
16+
deploy-infrastructure:
17+
runs-on: ubuntu-latest
18+
defaults:
19+
run:
20+
working-directory: ./infrastructure
21+
steps:
22+
- uses: actions/checkout@v2.3.2
23+
- uses: hashicorp/setup-terraform@v1
24+
25+
- name: Check Format
26+
run: terraform fmt -check -diff
27+
28+
- name: Validate
29+
run: terraform validate
30+
31+
- name: Bootstrap
32+
run: ./bootstrap.sh
33+
34+
- name: Init Terraform
35+
run: terraform init -input=false
36+
37+
- name: Deploy Infrastructure
38+
run: terraform apply -input=false -auto-approve
39+
40+
deploy-backend:
41+
runs-on: ubuntu-latest
42+
needs:
43+
- deploy-infrastructure
44+
defaults:
45+
run:
46+
working-directory: ./backend
47+
steps:
48+
- uses: actions/checkout@v2.3.2
49+
- uses: actions/setup-node@v2.1.1
50+
with:
51+
node-version: "12"
52+
- name: Restore npm cache
53+
uses: actions/cache@v2
54+
with:
55+
path: ~/.npm
56+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
57+
restore-keys: |
58+
${{ runner.os }}-node-
59+
60+
- name: Install dependencies
61+
run: npm ci
62+
63+
- name: Deploy Backend
64+
run: npm run deploy

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ geoip-data
3030
npm-debug.log*
3131
yarn-debug.log*
3232
yarn-error.log\*
33+
34+
terraform.tfvars
35+
.terraform
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
"AWSTemplateFormatVersion": "2010-09-09",
3+
"Description": "The AWS CloudFormation template for this Serverless application",
4+
"Resources": {
5+
"ServerlessDeploymentBucket": {
6+
"Type": "AWS::S3::Bucket",
7+
"Properties": {
8+
"BucketEncryption": {
9+
"ServerSideEncryptionConfiguration": [
10+
{
11+
"ServerSideEncryptionByDefault": {
12+
"SSEAlgorithm": "AES256"
13+
}
14+
}
15+
]
16+
}
17+
}
18+
},
19+
"ServerlessDeploymentBucketPolicy": {
20+
"Type": "AWS::S3::BucketPolicy",
21+
"Properties": {
22+
"Bucket": {
23+
"Ref": "ServerlessDeploymentBucket"
24+
},
25+
"PolicyDocument": {
26+
"Statement": [
27+
{
28+
"Action": "s3:*",
29+
"Effect": "Deny",
30+
"Principal": "*",
31+
"Resource": [
32+
{
33+
"Fn::Join": [
34+
"",
35+
[
36+
"arn:",
37+
{
38+
"Ref": "AWS::Partition"
39+
},
40+
":s3:::",
41+
{
42+
"Ref": "ServerlessDeploymentBucket"
43+
},
44+
"/*"
45+
]
46+
]
47+
}
48+
],
49+
"Condition": {
50+
"Bool": {
51+
"aws:SecureTransport": false
52+
}
53+
}
54+
}
55+
]
56+
}
57+
}
58+
}
59+
},
60+
"Outputs": {
61+
"ServerlessDeploymentBucketName": {
62+
"Value": {
63+
"Ref": "ServerlessDeploymentBucket"
64+
}
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)