-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (60 loc) · 2.88 KB
/
production_deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
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