Skip to content

fix: 임시 배포 설정 #84

fix: 임시 배포 설정

fix: 임시 배포 설정 #84

Workflow file for this run

name: Deploy to Amazon ECR
on:
push:
branches: [ main ]
workflow_dispatch:
jobs:
deploy:
name: Build and Push Docker image to Amazon ECR
runs-on: ubuntu-latest
env:
IMAGE_TAG: ${{ github.run_number }}
ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: set credentials
uses: microsoft/variable-substitution@v1
with:
files: './src/main/resources/application-prod.yaml'
env:
spring.datasource.url: ${{ secrets.AWS_DATASOURCE_URL }}
spring.datasource.username: ${{ secrets.AWS_RDS_USERNAME }}
spring.datasource.password: ${{ secrets.AWS_RDS_PASSWORD }}
spring.data.redis.host: ${{ secrets.AWS_ELASTICACHE_HOST }}
spring.data.redis.database: ${{ secrets.AWS_ELASTICACHE_DATABASE }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG