Skip to content

Commit bae9656

Browse files
Lucas BeloLucas Belo
authored andcommitted
Deployment workflow and destroy resources workflow
1 parent 5db0114 commit bae9656

File tree

3 files changed

+98
-0
lines changed

3 files changed

+98
-0
lines changed

.github/workflows/destroy.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Destroy cloud resources
2+
on: workflow_dispatch
3+
env:
4+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
5+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
6+
AWS_DEFAULT_REGION: eu-west-1
7+
APP_ENVIRONMENT: development
8+
jobs:
9+
destroy-global-infrastructure:
10+
runs-on: ubuntu-latest
11+
defaults:
12+
run:
13+
working-directory: infrastructure
14+
steps:
15+
- uses: actions/checkout@v3
16+
- name: Destroy global infrastructure
17+
run: aws cloudformation delete-stack --stack-name ${APP_ENVIRONMENT}-tasks-check
18+
destroy-api:
19+
needs: [destroy-global-infrastructure]
20+
runs-on: ubuntu-latest
21+
defaults:
22+
run:
23+
working-directory: services/tasks_api
24+
steps:
25+
- name: Checkout Code
26+
uses: actions/checkout@v3
27+
- uses: actions/setup-node@v3
28+
with:
29+
node-version: '16.x'
30+
- name: Install Serverless Framework
31+
run: npm install -g serverless
32+
- name: Install NPM dependencies
33+
run: npm install
34+
- name: Destroy
35+
run: sls remove --stage development --verbose
36+
destroy-ui:
37+
needs: [destroy-global-infrastructure]
38+
runs-on: ubuntu-latest
39+
defaults:
40+
run:
41+
working-directory: services/tasks_ui
42+
steps:
43+
- name: Checkout Code
44+
uses: actions/checkout@v3
45+
- uses: actions/setup-node@v3
46+
with:
47+
node-version: '16.x'
48+
- name: Install Serverless Framework
49+
run: npm install -g serverless
50+
- name: Install NPM dependencies
51+
run: npm install
52+
- name: Destroy
53+
run: sls remove --stage development --verbose

.github/workflows/infrastructure.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Apply infrastructure changes
2+
on:
3+
push:
4+
paths:
5+
- 'infrastructure/**'
6+
- '.github/workflows/infrastructure.yml'
7+
8+
env:
9+
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
10+
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
11+
AWS_DEFAULT_REGION: eu-west-1
12+
APP_ENVIRONMENT: development
13+
APP_DOMAIN: your-domain.com
14+
15+
16+
jobs:
17+
apply:
18+
runs-on: ubuntu-latest
19+
defaults:
20+
run:
21+
working-directory: infrastructure
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Apply changes
25+
run: aws cloudformation deploy --template-file cf_tasks.yml --stack-name ${APP_ENVIRONMENT}-tasks --parameter-overrides Domain=${APP_DOMAIN}

infrastructure/cf_tasks.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
AWSTemplateFormatVersion: '2010-09-09'
2+
Parameters:
3+
Domain:
4+
Type: String
5+
Description: The DNS name of an existing Amazon Route 53 hosted zone
6+
AllowedPattern: "(?!-)[a-zA-Z0-9-.]{1,63}(?<!-)"
7+
ConstraintDescription: must be a valid DNS zone name.
8+
Resources:
9+
TasksHostedZone:
10+
Type: AWS::Route53::HostedZone
11+
Properties:
12+
HostedZoneConfig:
13+
HostedZoneConfig
14+
Name:
15+
Ref: Domain
16+
Outputs:
17+
HostedZoneId:
18+
Description: Hosted zone ID
19+
Value:
20+
Ref: TasksHostedZone

0 commit comments

Comments
 (0)