-
Notifications
You must be signed in to change notification settings - Fork 0
[Feat] AWS EC2 연결 추가 #7
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,33 +1,48 @@ | ||
| name: Deploy to cloudtype | ||
| name: Deploy EC2 | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| push: | ||
| branches: | ||
| - dev | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
| - name: Connect deploy key | ||
| uses: cloudtype-github-actions/connect@v1 | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up JDK 17 | ||
| uses: actions/setup-java@v4 | ||
| with: | ||
| token: ${{ secrets.CLOUDTYPE_TOKEN }} | ||
| ghtoken: ${{ secrets.GHP_TOKEN }} | ||
| - name: Deploy | ||
| uses: cloudtype-github-actions/deploy@v1 | ||
| java-version: '17' | ||
| distribution: 'corretto' | ||
|
|
||
| - name: Grant execute permission for gradlew | ||
| run: chmod +x ./gradlew | ||
|
|
||
| - name: gradlew bootJar | ||
| run: ./gradlew bootJar | ||
|
|
||
| - name: copy jar to server | ||
| uses: appleboy/scp-action@master | ||
| with: | ||
| token: ${{ secrets.CLOUDTYPE_TOKEN }} | ||
| project: hyewon-0607/mse-project | ||
| stage: main | ||
| yaml: | | ||
| name: mse-project | ||
| app: java@17 | ||
| options: | ||
| ports: 8080 | ||
| context: | ||
| git: | ||
| url: git@github.com:${{ github.repository }}.git | ||
| ref: ${{ github.ref }} | ||
| preset: java-springboot | ||
| host: ${{ secrets.SSH_HOST }} | ||
| username: ec2-user | ||
| key: ${{ secrets.SSH_KEY }} | ||
| port: 22 | ||
| source: "build/libs/*.jar" | ||
| target: "/home/ec2-user/app" | ||
|
Comment on lines
+35
to
+36
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SCP 전송 시 디렉토리 구조가 보존되어 파일 경로가 의도와 다릅니다.
제안 - name: copy jar to server
- uses: appleboy/scp-action@master
+ uses: appleboy/scp-action@v1.0.0
with:
host: ${{ secrets.SSH_HOST }}
username: ec2-user
key: ${{ secrets.SSH_KEY }}
port: 22
source: "build/libs/*.jar"
target: "/home/ec2-user/app"
+ strip_components: 2🤖 Prompt for AI Agents |
||
|
|
||
| - name: Deploy with Docker Compose | ||
| uses: appleboy/ssh-action@v0.1.6 | ||
| with: | ||
| host: ${{ secrets.SSH_HOST }} | ||
| username: ec2-user | ||
| key: ${{ secrets.SSH_KEY }} | ||
| port: 22 | ||
| script: | | ||
| cd /home/ec2-user/app | ||
| docker-compose down | ||
| docker-compose up -d --build | ||
|
Comment on lines
+38
to
+48
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. EC2에 워크플로우는 JAR 파일만 EC2로 복사하지만, SSH 단계에서 해결 방안:
🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,22 +1,37 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: "3" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: "3.8" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| services: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| build: . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container_name: mse-app | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - "8080:8080" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SPRING_PROFILES_ACTIVE: docker | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MYSQL_USER: ${MYSQL_USER} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MYSQL_PASSWORD: ${MYSQL_PASSWORD} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| depends_on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - mysql | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - redis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| mysql: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: mysql:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: mysql:8.0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container_name: mse-mysql | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - "23306:3306" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MYSQL_DATABASE: ${MYSQL_DATABASE} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MYSQL_USER: ${MYSQL_USER} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| MYSQL_PASSWORD: ${MYSQL_PASSWORD} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
17
to
+27
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MySQL 데이터 영속성을 위한 볼륨이 없습니다.
제안: 볼륨 추가 mysql:
image: mysql:8.0
container_name: mse-mysql
ports:
- "23306:3306"
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
+ volumes:
+ - mysql-data:/var/lib/mysql
+
+volumes:
+ mysql-data:📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| redis: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: redis:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: redis:7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| container_name: mse-redis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - "26379:6379" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||
| nginx: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| image: nginx:latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ports: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - "80:80" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| depends_on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - redis | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - mysql | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| # certification | ||
| spring.config.import=optional:application-local-secret.properties | ||
|
|
||
| # MySQL | ||
| spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver | ||
| spring.datasource.url=jdbc:mysql://localhost:3306/mse_db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
appleboy/scp-action latest release GitHub💡 Result:
The latest GitHub release of
appleboy/scp-actionis v1.0.0 (tag:v1.0.0), published Apr 27 (04:42) and marked Latest on the repo’s Releases page. [1]GitHub Marketplace also shows the latest version as v1.0.0. [2]
Use in workflow:
uses: appleboy/scp-action@v1(or pin@v1.0.0). [2]Sources: [1] [2]
appleboy/scp-action@master를 특정 버전으로 고정하세요.@master를 사용하면 업스트림 변경이나 공급망 공격에 취약합니다.ssh-action은 특정 버전으로 고정되어 있으므로scp-action도 동일하게 버전을 고정해야 합니다. 현재 최신 버전은v1.0.0입니다.제안
📝 Committable suggestion
🤖 Prompt for AI Agents