Repository navigation
65 lines (54 loc) · 1.8 KB
/
Copy pathevent-service-deploy.yml
File metadata and controls
65 lines (54 loc) · 1.8 KB
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
name: Deploy Event Service to Amazon ECS
on:
push:
# branches: [ "main" ]
# # PRO TIP: Only run this pipeline if files in the event-service folder change
# paths:
# - 'event-service/**'
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: event-service
ECS_SERVICE: event-service
ECS_CLUSTER: stream-seat-cluster
CONTAINER_NAME: event-service-container
jobs:
deploy:
runs-on: ubuntu-latest
# This tells GitHub to run all 'run' commands inside the event-service directory
defaults:
run:
working-directory: ./event-service
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build JAR with Maven
run: mvn clean package -DskipTests
- 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: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, Tag, and Push Image to ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
# buildx is used for AMD64 compatibility on Fargate
docker buildx create --use
docker buildx build --platform linux/amd64 \
-t $ECR_REGISTRY/$ECR_REPOSITORY:latest \
--push .
- name: Force ECS Deployment
run: |
aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} \
--service ${{ env.ECS_SERVICE }} \
--force-new-deployment