-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (58 loc) · 2.41 KB
/
deploy-stg.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
name: Deploy Staging Image
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'src/**'
env:
AWS_REGION: us-west-2
ECR_REPOSITORY: 992382730467.dkr.ecr.us-west-2.amazonaws.com/staging-kogo-content-backend
ACTIVE_PROFILE: stg
jobs:
deploy-staging:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 21
- name: Setup AWS CLI
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: ecr_login
uses: aws-actions/amazon-ecr-login@v1
- name: Generate Timestamp
id: timestamp
run: echo "TIMESTAMP=$(date +'%Y%m%d-%H%M%S')" >> $GITHUB_ENV
- name: Extract KCB_VERSION from build.gradle.kts
id: extract_version
run: |
VERSION=$(grep "^version" build.gradle.kts | sed 's/version = "\(.*\)"/\1/')
echo "KCB_VERSION=$VERSION" >> $GITHUB_ENV
- name: Build with Gradle (stg profile)
run: ./gradlew clean build -x test
- name: Build Docker image
run: |
COMMIT_HASH=${{ github.sha }}
docker build \
--build-arg KCB_VERSION=${{ env.KCB_VERSION }} \
--build-arg ACTIVE_PROFILE=${{ env.ACTIVE_PROFILE }} \
--build-arg AWS_ACCESS_KEY_ID=${{ env.AWS_ACCESS_KEY_ID }} \
--build-arg AWS_SECRET_ACCESS_KEY=${{ env.AWS_SECRET_ACCESS_KEY }} \
--build-arg AWS_REGION=${{ env.AWS_REGION }} \
-t ${{ env.ECR_REPOSITORY }}:latest \
-t ${{ env.ECR_REPOSITORY }}:${{ env.TIMESTAMP }}-${COMMIT_HASH::7} \
.
- name: Push Docker images to ECR
run: |
docker push ${{ env.ECR_REPOSITORY }} --all-tags
- name: Run App Runner Deployment
run: ./bin/deploy-apprunner-stg.sh --auto