Skip to content

Deploy Crusher Server #401

Deploy Crusher Server

Deploy Crusher Server #401

name: Deploy Crusher Server
on:
release:
types: [published, edited]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: pnpm/action-setup@v2.2.2
with:
version: 7.5.1
- name: Setup Node.js environment
uses: actions/setup-node@v3
with:
node-version: 16.20.0
cache: 'pnpm'
- name: Create ecosystem.config.js
run: cp ecosystem.config.sample.js ecosystem.config.js
- name: Copy .env.sample file
run: cp .env.sample .env
- name: Install crusher modules
run: pnpm install --frozen-lockfile
- name: Setup crusher
run: pnpm setup:prod
- name: Install ncc
run: npm install -g @vercel/ncc@0.27.0
- name: Upgrade heap size of node
run: export NODE_OPTIONS=--max_old_space_size=4096
- name: Package crusher-server for deployment
run: sh scripts/build/build-crusher-server.sh
env:
NODE_OPTIONS: --max_old_space_size=4096
- name: Delete main node_modules
run: rm -R node_modules
- 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: us-east-1
- 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:
CRUSHER_ENV: production
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: crusher-server-images
REDIS_HOST: ${{ secrets.REDIS_HOST }}
REDIS_PORT: ${{ secrets.REDIS_PORT }}
REDIS_PASSWORD: ${{ secrets.REDIS_PASSWORD }}
IMAGE_TAG: latest
PORT: 80
run: |
export DOCKER_BUILDKIT=1
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . --file docker/ee/crusher-server/Dockerfile --build-arg PORT=80 --build-arg REDIS_HOST=$REDIS_HOST --build-arg REDIS_PASSWORD=$REDIS_PASSWORD --build-arg REDIS_PORT=$REDIS_PORT
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
- name: Download task definition
run: |
aws ecs describe-task-definition --task-definition TestCompleteProcessorV1 --query taskDefinition > task-definition.json
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: task-definition.json
container-name: TaskResultProcessor
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: crusher-test-result-processor
cluster: crusher-test-runner
wait-for-service-stability: false