Create workflow + aux scripts for build/deploy

This commit is contained in:
Nick Tampakas
2024-11-06 10:15:05 +02:00
parent 8489c780da
commit 29da69843d
3 changed files with 62 additions and 0 deletions

13
.github/scripts/build.sh vendored Executable file
View File

@@ -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
.github/scripts/deploy.sh vendored Executable file
View File

@@ -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
.github/workflows/deploy.yml vendored Normal file
View File

@@ -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