Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ecs deploy #9

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 20 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

env:
AWS_REGION: ap-southeast-2
FAMILY: api-service
TAG: ${{ github.event.release.tag_name }}

permissions:
Expand Down Expand Up @@ -76,47 +77,37 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Render api definition
id: render-api-definition
uses: aws-actions/amazon-ecs-render-task-definition@v1
- name: Configure AWS Credentials
if: ${{ !env.ACT }}
uses: aws-actions/configure-aws-credentials@v4
with:
task-definition: ./templates/api_definition.json
container-name: api
image: 450356697252.dkr.ecr.ap-southeast-2.amazonaws.com/api:${{ env.TAG }}
environment-variables: |
DJANGO_SECRET_KEY=change_me
DB_HOST=${{ vars.DB_HOST }}
DB_NAME=api
DB_USER=api
DB_SECRET_NAME=${{ vars.DB_SECRET_NAME }}
DB_SECRET_REGION=${{ vars.DB_SECRET_REGION }}
ALLOWED_HOSTS=*
ALLOWED_CIDR_NETS=10.32.48.0/20,10.32.64.0/20,10.32.80.0/20
S3_STORAGE_BUCKET_NAME=api-bucket-450356697252
S3_STORAGE_BUCKET_REGION=ap-southeast-2

- name: Render nginx proxy definition
id: render-proxy-definition
audience: sts.amazonaws.com
aws-region: ${{ env.AWS_REGION }}
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}

- name: Get Current Task Definition
id: get-current-task-definition
run: |
aws ecs describe-task-definition --task-definition ${{ env.FAMILY }} --query taskDefinition > task-definition.json

- name: Update API image tag
id: update-api-image-tag
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.render-api-definition.outputs.task-definition }}
container-name: proxy
image: 450356697252.dkr.ecr.ap-southeast-2.amazonaws.com/nginx:latest
environment-variables: |
APP_HOST=127.0.0.1
APP_PORT=9000
LISTEN_PORT=80
task-definition: task-definition.json
container-name: api
image: 450356697252.dkr.ecr.ap-southeast-2.amazonaws.com/nginx:${{ env.TAG }}

- name: Display Rendered Template
if: ${{ env.ACT }}
id: display-rendered-template
run: cat ${{ steps.render-proxy-definition.outputs.task-definition }} | jq -r
run: cat ${{ steps.update-api-image-tag.outputs.task-definition }} | jq -r

- name: Deploy to Amazon ECS service
if: ${{ !env.ACT }}
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-proxy-definition.outputs.task-definition }}
task-definition: ${{ steps.update-api-image-tag.outputs.task-definition }}
service: api-service
cluster: api-cluster
force-new-deployment: true
Expand Down
56 changes: 0 additions & 56 deletions templates/api_definition.json

This file was deleted.

Loading