Auth 모듈 스프링 서버로 이전(~ing) #9
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Server Spring CD | |
on: | |
pull_request: | |
branches: ["develop", "main"] | |
paths: | |
- "server/spring/**" | |
types: | |
- closed | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: "17" | |
distribution: "adopt" | |
- name: Run chmod to make gradlew executable | |
run: | | |
cd server/spring | |
chmod +x ./gradlew | |
- name: Build with Gradle | |
run: | | |
cd server/spring | |
./gradlew clean build | |
- name: Create application.yml | |
env: | |
DB_HOST_IP: ${{ secrets.SERVER_ENV_DB_HOST_IP }} | |
DB_PORT: ${{ secrets.SERVER_ENV_DB_PORT }} | |
DB_USER_NAME: ${{ secrets.SERVER_ENV_DB_USER_NAME }} | |
DB_PASSWORD: ${{ secrets.SERVER_ENV_DB_PASSWORD }} | |
DB_DATABASE_NAME: ${{ secrets.SERVER_ENV_DB_DATABASE_NAME }} | |
ACCESS_ID: ${{ secrets.SERVER_ENV_ACCESS_ID }} | |
SECRET_ACCESS_KEY: ${{ secrets.SERVER_ENV_SECRET_ACCESS_KEY }} | |
JWT_SECRET_KEY: ${{ secrets.SERVER_ENV_JWT_SECRET_KEY }} | |
GREEN_EYE_SECRET_KEY: ${{secrets.GREEN_EYE_SECRET_KEY}} | |
GREEN_EYE_REQUEST_URL: ${{secrets.GREEN_EYE_REQUEST_URL}} | |
CLOUD_FUNCTIONS_EXECUTE_URL: ${{secrets.CLOUD_FUNCTIONS_EXECUTE_URL}} | |
CLOUD_FUNCTIONS_REQUEST_URL: ${{secrets.CLOUD_FUNCTIONS_REQUEST_URL}} | |
API_GW_ACCESS_KEY: ${{secrets.API_GW_ACCESS_KEY}} | |
REFRESH_SECRET_KEY: ${{secrets.REFRESH_SECRET_KEY}} | |
REDIS_HOST_IP: ${{secrets.REDIS_HOST_IP}} | |
REDIS_PASSWORD: ${{secrets.REDIS_PASSWORD}} | |
REDIS_PORT: ${{secrets.REDIS_PORT}} | |
REDIS_TTL: ${{secrets.REDIS_TTL}} | |
run: | | |
cd server/spring | |
touch ./application.yml | |
echo "DB_HOST_IP=$DB_HOST_IP" >> application.yml | |
echo "DB_PORT=$DB_PORT" >> application.yml | |
echo "DB_USER_NAME=$DB_USER_NAME" >> application.yml | |
echo "DB_PASSWORD=$DB_PASSWORD" >> application.yml | |
echo "DB_DATABASE_NAME=$DB_DATABASE_NAME" >> application.yml | |
echo "ACCESS_ID=$ACCESS_ID" >> application.yml | |
echo "SECRET_ACCESS_KEY=$SECRET_ACCESS_KEY" >> application.yml | |
echo "JWT_SECRET_KEY=$JWT_SECRET_KEY" >> application.yml | |
echo "GREEN_EYE_SECRET_KEY=$GREEN_EYE_SECRET_KEY" >> application.yml | |
echo "GREEN_EYE_REQUEST_URL=$GREEN_EYE_REQUEST_URL" >> application.yml | |
echo "CLOUD_FUNCTIONS_EXECUTE_URL=$CLOUD_FUNCTIONS_EXECUTE_URL" >> application.yml | |
echo "CLOUD_FUNCTIONS_REQUEST_URL=$CLOUD_FUNCTIONS_REQUEST_URL" >> application.yml | |
echo "API_GW_ACCESS_KEY=$API_GW_ACCESS_KEY" >> application.yml | |
echo "REFRESH_SECRET_KEY=$REFRESH_SECRET_KEY" >> application.yml | |
echo "REDIS_HOST_IP=$REDIS_HOST_IP" >> application.yml | |
echo "REDIS_PASSWORD=$REDIS_PASSWORD" >> application.yml | |
echo "REDIS_PORT=$REDIS_PORT" >> application.yml | |
echo "REDIS_TTL=$REDIS_TTL" >> application.yml | |
- name: Build Docker image | |
run: docker build --platform linux/amd64 ./server -t ${{ secrets.NCP_SPRING_REGISTRY }}/catchy-tape-sub:latest -f ./server/Dockerfile.spring | |
- name: Login NCP container registry | |
run: docker login ${{ secrets.NCP_SPRING_REGISTRY }} -u ${{ secrets.NCP_DOCKER_ACCESS_KEY_ID }} -p ${{ secrets.NCP_DOCKER_SECRET_KEY }} | |
- name: Push Docker image to registry | |
run: docker push ${{ secrets.NCP_SPRING_REGISTRY }}/catchy-tape-sub:latest | |
- name: SSH into Server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_SSH_HOST }} | |
username: ${{ secrets.SERVER_SSH_USER }} | |
password: ${{ secrets.SERVER_SSH_PASSWORD }} | |
port: ${{ secrets.SERVER_SSH_PORT }} | |
script: | | |
export NCP_SPRING_REGISTRY=${{ secrets.NCP_SPRING_REGISTRY }} | |
export NCP_DOCKER_ACCESS_KEY_ID=${{ secrets.NCP_DOCKER_ACCESS_KEY_ID }} | |
export NCP_DOCKER_SECRET_KEY=${{ secrets.NCP_DOCKER_SECRET_KEY }} | |
sh server/deploy-spring.sh | |
curl -X POST -H 'Content-type: application/json' --data '{"text":"스프링 서버 배포 성공!"}' ${{ secrets.SLACK_WEBHOOK_URL }} |