fix(#3): 커밋 컨벤션 feat 수정 #27
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: ci cd | |
on: | |
push: | |
branches: | |
- develop | |
- main | |
pull_request: | |
branches: | |
- develop | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Grant execute permission for gradlew | |
run: chmod u+x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
- name: Build and push Docker image | |
env: | |
DOCKER_USER: ${{secrets.DOCKER_USER}} | |
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}} | |
run: | | |
docker login -u $DOCKER_USER -p $DOCKER_PASSWORD | |
docker build -t $DOCKER_USER/testimage . | |
docker push $DOCKER_USER/testimage | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Deploy to EC2 | |
env: | |
SSH_KEY: ${{secrets.EC2_SSH_KEY}} | |
URL: ${{secrets.EC2_URL}} | |
USER: ${{secrets.EC2_USER}} | |
DOCKER_USER: ${{secrets.DOCKER_USER}} | |
run: | | |
echo "$SSH_KEY" > private_key.pem | |
chmod 600 private_key.pem | |
ssh -i private_key.pem -o StrictHostKeyChecking=no $USER@$URL "\ | |
sudo docker stop spring-server || true && \ | |
sudo docker rm spring-server || true && \ | |
sudo docker pull $DOCKER_USER/testimage:latest && \ | |
sudo docker run -d --name spring-server -p 8080:8080 $DOCKER_USER/testimage:latest" | |
rm -f private_key.pem | |