Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/203 deploy server cicd #205

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ name: Develop

on:
push:
branches: [ "main" ]
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]


permissions:
contents: read
Expand Down Expand Up @@ -30,7 +33,7 @@ jobs:
run: |
cd ./src/main/resources
touch ./env.properties
echo "${{ secrets.ENV }}" > ./env.properties
echo "${{ secrets.ENV_DEVELOP }}" > ./env.properties
shell: bash
# Gradle build (Test μ œμ™Έ)
- name: Build with Gradle
Expand All @@ -41,18 +44,20 @@ jobs:
- name: Docker build
run: |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }}
docker build -t atties_spring .
docker tag atties_spring choo000407/atties_spring:${GITHUB_SHA::7}
docker push choo000407/atties_spring:${GITHUB_SHA::7}
docker build -t atties_dev_spring .
docker tag atties_dev_spring choo000407/atties_dev_spring:${GITHUB_SHA::7}
docker push choo000407/atties_dev_spring:${GITHUB_SHA::7}
# Deploy
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ec2-44-193-163-114.compute-1.amazonaws.com
username: ec2-user
password: ${{ secrets.SSH_PASSWORD }}
host: 43.200.100.183
username: ubuntu
key: ${{ secrets.SSH_PRIVATE_KEY_DEVELOP }}
passphrase: ${{ secrets.SSH_PASSPHRASE }}
port: 22
envs: GITHUB_SHA
script: |
docker pull choo000407/atties_spring:${GITHUB_SHA::7}
docker tag choo000407/atties_spring:${GITHUB_SHA::7} atties_spring
docker-compose up -d
sudo docker pull choo000407/atties_dev_spring:${GITHUB_SHA::7}
sudo docker tag choo000407/atties_dev_spring:${GITHUB_SHA::7} atties_dev_spring
sudo docker-compose up -d
5 changes: 3 additions & 2 deletions src/main/java/com/sptp/backend/aws/service/AwsService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.amazonaws.services.s3.model.CannedAccessControlList;
import com.amazonaws.services.s3.model.ObjectMetadata;
import com.amazonaws.services.s3.model.PutObjectRequest;
import com.amazonaws.services.s3.model.S3Object;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

Expand All @@ -19,7 +19,8 @@ public class AwsService {

private final AmazonS3Client amazonS3Client;

private final String S3Bucket = "atties-bucket";
@Value("${aws.storage.name}")
private String S3Bucket; // develop "atties-dev-storage", main "atties-bucket"

public void uploadImage(MultipartFile image, String uuid) throws IOException {

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# λ°°ν¬μ‹œ 80포트 μ„€μ •
server:
port: 80
#server:
# port: 8080

spring:

Expand Down