Skip to content

Commit

Permalink
feat: deploy to aws
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewPattell committed Jul 13, 2023
1 parent b3683ca commit 5bb33c0
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 1 deletion.
100 changes: 100 additions & 0 deletions .github/task-definition.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
{
"ipcMode": null,
"executionRoleArn": "arn:aws:iam::771350349623:role/ECSTaskDefinitionRole",
"containerDefinitions": [
{
"dnsSearchDomains": null,
"environmentFiles": null,
"logConfiguration": {
"logDriver": "none",
"secretOptions": null,
"options": null
},
"entryPoint": [],
"portMappings": [
{
"hostPort": 0,
"protocol": "tcp",
"containerPort": 3000
}
],
"command": [],
"linuxParameters": null,
"cpu": 0,
"environment": [],
"resourceRequirements": null,
"ulimits": null,
"repositoryCredentials": {
"credentialsParameter": "arn:aws:secretsmanager:eu-west-1:771350349623:secret:ecs/docker-github-EvtP4B"
},
"dnsServers": null,
"mountPoints": [],
"workingDirectory": null,
"secrets": null,
"dockerSecurityOptions": null,
"memory": null,
"memoryReservation": null,
"volumesFrom": [],
"stopTimeout": null,
"image": "ghcr.io/lomray-software/vite-template/web:latest-prod",
"startTimeout": null,
"firelensConfiguration": null,
"dependsOn": null,
"disableNetworking": null,
"interactive": null,
"healthCheck": null,
"essential": true,
"links": null,
"hostname": null,
"extraHosts": null,
"pseudoTerminal": null,
"user": null,
"readonlyRootFilesystem": null,
"dockerLabels": null,
"systemControls": null,
"privileged": null,
"name": "web"
}
],
"placementConstraints": [],
"memory": "100",
"taskRoleArn": "arn:aws:iam::771350349623:role/ECSTaskDefinitionRole",
"compatibilities": [
"EXTERNAL",
"EC2"
],
"taskDefinitionArn": "arn:aws:ecs:eu-west-1:771350349623:task-definition/vite-template:2",
"family": "vite-template",
"requiresAttributes": [
{
"targetId": null,
"targetType": null,
"value": null,
"name": "ecs.capability.private-registry-authentication.secretsmanager"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.task-iam-role"
},
{
"targetId": null,
"targetType": null,
"value": null,
"name": "com.amazonaws.ecs.capability.docker-remote-api.1.18"
}
],
"pidMode": null,
"requiresCompatibilities": [
"EC2"
],
"networkMode": "bridge",
"runtimePlatform": null,
"cpu": null,
"revision": 2,
"status": "ACTIVE",
"inferenceAccelerators": null,
"proxyConfiguration": null,
"volumes": []
}
37 changes: 36 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ on:
branches: [ prod, staging ]

env:
NODE_VERSION: 18.13.0
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/web
ECS_TASK_DEFINITION: ./.github/task-definition.json
ECS_TASK_CONTAINER_NAME: web
ECS_SERVICE: vite-template
ECS_CLUSTER: Development

jobs:
build:
Expand All @@ -22,7 +27,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: '18.13.0'
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Install dependencies
Expand Down Expand Up @@ -113,6 +118,36 @@ jobs:
build-args: |
BUILD_PATH=./build
deploy:
needs: [ docker-build ]
runs-on: ubuntu-latest
concurrency:
group: ${{ github.ref }}-deploy
cancel-in-progress: true

steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
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: Update AWS ECS Task Definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.ECS_TASK_CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}

- name: Deploy AWS ECS Task Definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}

release:
needs: [build, docker-build]
runs-on: ubuntu-latest
Expand Down

0 comments on commit 5bb33c0

Please sign in to comment.