Production Deploy #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "Production Deploy" | |
on: | |
# push: | |
# branches: [ "main" ] | |
# # Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
env: | |
AWS_REGION: "eu-west-2" # set this to your preferred AWS region, e.g. us-west-1 | |
ECR_REPOSITORY: "rapidresearch-production-grobid-ecr-repository" # set this to your Amazon ECR repository name | |
ECS_SERVICE: "grobid-service" # set this to your Amazon ECS service name | |
ECS_CLUSTER: "rapidresearch-ecs-cluster" # set this to your Amazon ECS cluster name | |
CONTAINER_NAME: "grobids-friend" # set this to the name of the container in the | |
TASK_DEFINITION: "grobid-task-production" # set this to the name of the container in the | |
# containerDefinitions section of your task definition | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- name: ConfigureAWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY}} | |
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Login to AmazonECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: docker build | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{steps.login-ecr.outputs.registry}} | |
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} | |
IMAGE_TAG: "latest" | |
run: | | |
export WWWUSER=${WWWUSER:-$UID} | |
export WWWGROUP=${WWWGROUP:-$(id -g)} | |
docker-compose -f docker-compose-prod.yaml build | |
docker tag grobids-friend:latest ${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG} | |
docker push ${ECR_REGISTRY}/${ECR_REPOSITORY}:${IMAGE_TAG} | |
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
- name: Download task definition | |
id: task-def-download | |
run: | | |
aws ecs describe-task-definition --task-definition ${{ env.TASK_DEFINITION }} --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@c804dfbdd57f713b6c079302a4c01db7017a36fc | |
with: | |
task-definition: task-definition.json | |
container-name: ${{ env.CONTAINER_NAME }} | |
image: ${{ steps.build-image.outputs.image }} | |
- name: Deploy Amazon ECS task definition | |
uses: aws-actions/amazon-ecs-deploy-task-definition@df9643053eda01f169e64a0e60233aacca83799a | |
with: | |
task-definition: ${{ steps.task-def.outputs.task-definition }} | |
service: ${{ env.ECS_SERVICE }} | |
cluster: ${{ env.ECS_CLUSTER }} | |
wait-for-service-stability: false |