Skip to content

RedisConfig 및 yml 수정 (#37) #63

RedisConfig 및 yml 수정 (#37)

RedisConfig 및 yml 수정 (#37) #63

Workflow file for this run

name: climbing
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
# CI
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Pull Redis Docker image
run: docker pull redis
- name: Run Redis container
run: docker run --name my-redis -d -p 6379:6379 redis
- name: Set AwsS3 Key at yaml
uses: microsoft/variable-substitution@v1
with:
files: ./src/main/resources/application-ci.yml, ./src/main/resources/application-prod.yml
env:
aws.s3.bucket: ${{ secrets.AWS_S3_BUCKET }}
aws.s3.accessKey: ${{ secrets.AWS_S3_ACCESS_KEY }}
aws.s3.secretKey: ${{ secrets.AWS_S3_SECRET_KEY }}
- name: Set RDS & REDIS at prod yaml
uses: microsoft/variable-substitution@v1
with:
files: ./src/main/resources/application-prod.yml
env:
spring.datasource.url: ${{ secrets.DB_URL }}
spring.datasource.username: ${{ secrets.DB_USERNAME }}
spring.datasource.password: ${{ secrets.DB_PASSWORD }}
redis.host: ${{ secrets.REDIS_HOSTNAME }}
- name: Grant execute permission to gradlew
run: chmod +x ./gradlew
- name: Build with Gradle
run: ./gradlew clean build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ap-northeast-2
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: climbing
IMAGE_TAG: latest
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
- name: Generate deployment package
run: |
mkdir -p deploy
cp Dockerrun.aws.json deploy/Dockerrun.aws.json
cd deploy && zip -r deploy.zip .
- name: Get current time
uses: 1466587594/get-current-time@v2
id: current-time # 현재 시간이 id에 담김
with:
format: YYYY-MM-DDTHH-mm-ss
utfOffset: "+09:00"
# EB에 배포
- name: Deploy to EB
uses: einaregilsson/beanstalk-deploy@v21
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY }}
aws_secret_key: ${{ secrets.AWS_SECRET_KEY }}
application_name: climbing-api
environment_name: Climbing-api-env
version_label: climbing-${{steps.current-time.outputs.formattedTime}}
region: ap-northeast-2
deployment_package: deploy/deploy.zip