Skip to content

Commit

Permalink
Merge pull request #8 from ntampakas/main
Browse files Browse the repository at this point in the history
Introduce GH Actions to trigger Fargate deployment
  • Loading branch information
Codetrauma authored Nov 7, 2024
2 parents 8489c78 + efb0fb3 commit ca2421d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .github/scripts/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -ex

# Download poaps
aws s3 cp s3://tlsn-plugin-demo/poaps.txt server/util/

aws ecr get-login-password --region eu-central-1 | docker login --username AWS --password-stdin 490752553772.dkr.ecr.eu-central-1.amazonaws.com

docker build -t tlsn-plugin-demo .
docker tag tlsn-plugin-demo:latest 490752553772.dkr.ecr.eu-central-1.amazonaws.com/tlsn-plugin-demo:latest
docker push 490752553772.dkr.ecr.eu-central-1.amazonaws.com/tlsn-plugin-demo:latest

exit 0
13 changes: 13 additions & 0 deletions .github/scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -ex

tasks="tlsn-plugin-demo"
for task in $tasks; do
revision=$(aws ecs describe-task-definition --task-definition $task --query "taskDefinition.revision")
aws ecs update-service --cluster tlsn-plugin-demo --service $task --force-new-deployment --task-definition $task:$revision
done

for loop in {1..3}; do
[ "$loop" -eq 3 ] && exit 1
aws ecs wait services-stable --cluster tlsn-plugin-demo --services $tasks && break || continue
done
36 changes: 36 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Deploy
on:
push:
branches: [ main ]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read

steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::490752553772:role/tlsn-plugin-demo-ecs-deploy-slc
role-duration-seconds: 1800
aws-region: eu-central-1

- name: Build and Push images to ECR
run: |
.github/scripts/build.sh
- name: Trigger Deployment
run: |
.github/scripts/deploy.sh
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:20-alpine

ARG PORT=3030
WORKDIR /app

COPY . .

RUN npm install
RUN touch server/util/poaps.txt
RUN touch server/util/assignments.json
RUN npm run build

EXPOSE ${PORT}
CMD ["node", "build/server/index.bundle.js"]

0 comments on commit ca2421d

Please sign in to comment.