Skip to content

Push development broken into 5 services, with seperated cpu per service. #31

Push development broken into 5 services, with seperated cpu per service.

Push development broken into 5 services, with seperated cpu per service. #31

name: Push Development
on:
push:
branches:
- "development"
env:
ECR_REPOSITORY: images
IMAGE_TAG: ${{ github.sha }}
jobs:
prepare:
name: Prepare
runs-on: ubuntu-20.04
outputs:
BRANCH_REF_SLUG: ${{ steps.branch_ref_slug.outputs.slug }}
if: startsWith( github.ref, 'refs/heads/dependabot/' ) != true
steps:
- uses: actions/checkout@v3
- name: Set branch ref slug
id: branch_ref_slug
run: |
SLUG=$(echo "${{ github.ref }}" |
iconv -t ascii//TRANSLIT |
sed -E 's#refs/[^\/]*/##' |
sed -E 's/[^a-zA-Z0-9]+/-/g' |
sed -E 's/^-+|-+$//g' |
tr A-Z a-z)
echo "BRANCH_REF_SLUG=$SLUG" >> $GITHUB_ENV
echo "slug=$SLUG" >> $GITHUB_OUTPUT
build:
name: Build
needs: [prepare]
environment:
name: ${{ needs.prepare.outputs.BRANCH_REF_SLUG }}
runs-on: ubuntu-20.04
if: startsWith( github.ref, 'refs/heads/dependabot/' ) != true
steps:
- uses: actions/checkout@v3
- name: Set Environment Specific Variables
run: |
echo "AWS_REGION="${{ vars.AWS_REGION }} >> $GITHUB_ENV
echo "ECS_CLUSTER="${{ vars.ECS_CLUSTER }} >> $GITHUB_ENV
echo "ECS_SERVICE="${{ vars.ECS_SERVICE }} >> $GITHUB_ENV
- uses: actions/setup-node@v2-beta
with:
node-version: "14"
- 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: ${{ vars.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
docker build \
--file Dockerfile \
-t $ECR_REGISTRY/$ECR_REPOSITORY:redash_$IMAGE_TAG \
-t $ECR_REGISTRY/$ECR_REPOSITORY:redash_latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:redash_$IMAGE_TAG
docker push $ECR_REGISTRY/$ECR_REPOSITORY:redash_latest
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:redash_$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Logout of Amazon ECR
if: always()
run: docker logout ${{ steps.login-ecr.outputs.registry }}
### Download and Update Server Task Definition
- name: Download Server Task Definition
run: |
pwd
aws ecs describe-task-definition --task-definition RedashDevelopmentV2Server --query taskDefinition > server-task-definition.json
- name: Add Image ID to Server Container
id: render-server-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: server-task-definition.json
container-name: Server
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS Server task definition Development
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-server-container.outputs.task-definition }}
service: Server
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true
### Download and Update Scheduler Task Definition
- name: Download Scheduler Task Definition
run: |
pwd
aws ecs describe-task-definition --task-definition RedashDevelopmentV2Scheduler --query taskDefinition > scheduler-task-definition.json
- name: Modify Amazon ECS task definition with Scheduler Container
id: render-scheduler-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: scheduler-task-definition.json
container-name: Scheduler
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS Server task definition Development
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-scheduler-container.outputs.task-definition }}
service: Scheduler
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true
### Download and Update Scheduler Task Definition
- name: Download Worker Task Definition
run: |
pwd
aws ecs describe-task-definition --task-definition RedashDevelopmentV2Workers --query taskDefinition > workers-task-definition.json
- name: Modify Amazon ECS task definition with AdHocWorker Container
id: render-adhocworker-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: workers-task-definition.json
container-name: AdHocWorker
image: ${{ steps.build-image.outputs.image }}
- name: Modify Amazon ECS task definition with Worker Container
id: render-worker-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.render-adhocworker-container.outputs.task-definition }}
container-name: Worker
image: ${{ steps.build-image.outputs.image }}
- name: Modify Amazon ECS task definition with ScheduledWorker Container for Production
id: render-scheduledworker-container
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ steps.render-worker-container.outputs.task-definition }}
container-name: ScheduledWorker
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS Server task definition Development
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.render-scheduledworker-container.outputs.task-definition }}
service: Workers
cluster: ${{ vars.ECS_CLUSTER }}
wait-for-service-stability: true