-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (37 loc) · 1.22 KB
/
build.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
on:
push:
branches: [prod]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }}
ECR_REPOSITORY: 571094861812.dkr.ecr.us-east-1.amazonaws.com/name-generator
PROD_IMAGE_TAG: prod-name-generator
CLUSTER_NAME: prod-name-generator
SERVICE_NAME: prod-name-generator-server
steps:
- uses: actions/checkout@v2
- name: login to AWS ECR
run: |
aws ecr get-login-password --region us-east-1 | docker login \
--username AWS --password-stdin \
${ECR_REPOSITORY}
- name: build image
run: |
docker build \
--build-arg AWS_SECRET_ACCESS_KEY \
--build-arg AWS_ACCESS_KEY_ID \
-t ${ECR_REPOSITORY}:commit_$(git rev-parse --short "$GITHUB_SHA") \
-t ${ECR_REPOSITORY}:${PROD_IMAGE_TAG} \
.
- name: push image
run: docker push --all-tags ${ECR_REPOSITORY}
- name: deploy
run: |
aws ecs update-service \
--region us-east-1 \
--cluster ${CLUSTER_NAME} \
--service ${SERVICE_NAME} \
--force-new-deployment