-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
225 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
.github/workflows/files/demo-production-task-definition.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"containerDefinitions": [ | ||
{ | ||
"name": "demo", | ||
"image": "howdi/chatkitty-demo:latest", | ||
"cpu": 0, | ||
"memoryReservation": 128, | ||
"portMappings": [ | ||
{ | ||
"containerPort": 80, | ||
"hostPort": 0, | ||
"protocol": "tcp" | ||
} | ||
], | ||
"essential": true, | ||
"environment": [], | ||
"mountPoints": [], | ||
"volumesFrom": [], | ||
"logConfiguration": { | ||
"logDriver": "awslogs", | ||
"options": { | ||
"awslogs-group": "awslogs-chatkitty-production", | ||
"awslogs-region": "us-east-1", | ||
"awslogs-stream-prefix": "demo" | ||
} | ||
} | ||
} | ||
], | ||
"family": "chatkitty-demo", | ||
"taskRoleArn": "arn:aws:iam::785157241395:role/dev-docker-task", | ||
"networkMode": "bridge", | ||
"volumes": [], | ||
"placementConstraints": [], | ||
"requiresCompatibilities": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"containerDefinitions": [ | ||
{ | ||
"name": "demo", | ||
"image": "howdi/chatkitty-demo:latest", | ||
"cpu": 0, | ||
"memoryReservation": 128, | ||
"portMappings": [ | ||
{ | ||
"containerPort": 80, | ||
"hostPort": 0, | ||
"protocol": "tcp" | ||
} | ||
], | ||
"essential": true, | ||
"environment": [], | ||
"mountPoints": [], | ||
"volumesFrom": [], | ||
"logConfiguration": { | ||
"logDriver": "awslogs", | ||
"options": { | ||
"awslogs-group": "awslogs-chatkitty-staging", | ||
"awslogs-region": "us-east-1", | ||
"awslogs-stream-prefix": "demo" | ||
} | ||
} | ||
} | ||
], | ||
"family": "chatkitty-staging-demo", | ||
"taskRoleArn": "arn:aws:iam::785157241395:role/dev-docker-task", | ||
"networkMode": "bridge", | ||
"volumes": [], | ||
"placementConstraints": [], | ||
"requiresCompatibilities": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: Release (Production) | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*.*.*' | ||
|
||
env: | ||
AWS_REGION: us-east-1 | ||
ECS_CLUSTER: howdi | ||
DEMO_ECS_SERVICE: chatkitty-demo | ||
DEMO_CONTAINER_NAME: demo | ||
DEMO_ECS_TASK_DEFINITION: .github/workflows/files/demo-production-task-definition.json | ||
|
||
jobs: | ||
release-demo: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node 16.x | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16.x' | ||
cache: 'yarn' | ||
cache-dependency-path: yarn.lock | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- 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: ${{ env.AWS_REGION }} | ||
|
||
- name: Build React application | ||
run: | | ||
yarn install --frozen-lockfile; | ||
yarn run build; | ||
- name: Generate image tags | ||
id: image-tags | ||
run: | | ||
echo "::set-output name=release-version-tag::$(git rev-parse --short HEAD)"; | ||
echo "::set-output name=image-tag::howdi/chatkitty-website:$(git describe --tags)"; | ||
- name: Build and push Docker image | ||
id: docker-build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
file: ./docker/Dockerfile | ||
push: true | ||
tags: ${{ steps.image-tags.outputs.image-tag }} | ||
cache-from: type=gha, scope=${{ github.workflow }} | ||
cache-to: type=gha, scope=${{ github.workflow }} | ||
|
||
- name: Fill out ECS task definition | ||
id: task-definition | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ${{ env.DEMO_ECS_TASK_DEFINITION }} | ||
container-name: ${{ env.DEMO_CONTAINER_NAME }} | ||
image: ${{ steps.image-tags.outputs.image-tag }} | ||
|
||
- name: Deploy ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-definition.outputs.task-definition }} | ||
service: ${{ env.DEMO_ECS_SERVICE }} | ||
cluster: ${{ env.ECS_CLUSTER }} | ||
wait-for-service-stability: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Release (Staging) | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
env: | ||
AWS_REGION: us-east-1 | ||
ECS_CLUSTER: howdi-dev | ||
DEMO_ECS_SERVICE: chatkitty-staging-demo | ||
DEMO_CONTAINER_NAME: demo | ||
DEMO_IMAGE_TAG: howdi/chatkitty-demo:latest | ||
DEMO_ECS_TASK_DEFINITION: .github/workflows/files/demo-staging-task-definition.json | ||
|
||
jobs: | ||
release-demo: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Use Node 16.x | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '16.x' | ||
cache: 'yarn' | ||
cache-dependency-path: yarn.lock | ||
|
||
- name: Set up Docker Buildx | ||
id: buildx | ||
uses: docker/setup-buildx-action@v1 | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v1 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | ||
|
||
- 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: ${{ env.AWS_REGION }} | ||
|
||
- name: Build React application | ||
run: | | ||
yarn install --frozen-lockfile; | ||
yarn run build; | ||
- name: Build and push Docker image | ||
id: docker-build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
file: ./docker/Dockerfile | ||
push: true | ||
tags: ${{ env.DEMO_IMAGE_TAG }} | ||
cache-from: type=gha, scope=${{ github.workflow }} | ||
cache-to: type=gha, scope=${{ github.workflow }} | ||
|
||
- name: Fill out ECS task definition | ||
id: task-definition | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ${{ env.DEMO_ECS_TASK_DEFINITION }} | ||
container-name: ${{ env.DEMO_CONTAINER_NAME }} | ||
image: ${{ env.DEMO_IMAGE_TAG }} | ||
|
||
- name: Deploy ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-definition.outputs.task-definition }} | ||
service: ${{ env.DEMO_ECS_SERVICE }} | ||
cluster: ${{ env.ECS_CLUSTER }} |