-
Notifications
You must be signed in to change notification settings - Fork 0
[feat] EC2 프론트엔드 자동 배포 워크플로우 추가 #37
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| name: Deploy Frontend | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main, dev] | ||
| types: [closed] | ||
|
|
||
| jobs: | ||
| deploy: | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install pnpm | ||
| uses: pnpm/action-setup@v4 | ||
| with: | ||
| version: 10.28.0 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'pnpm' | ||
|
|
||
| - name: Install dependencies | ||
| run: pnpm install --frozen-lockfile | ||
|
|
||
| - name: Build | ||
| run: pnpm build | ||
| env: | ||
| VITE_API_URL: ${{ secrets.VITE_API_URL }} | ||
| VITE_APP_URL: ${{ secrets.VITE_APP_URL }} | ||
|
|
||
| - name: Deploy to EC2 | ||
| uses: appleboy/scp-action@v0.1.7 | ||
| with: | ||
| host: ${{ secrets.EC2_HOST }} | ||
| username: ${{ secrets.EC2_USER }} | ||
| key: ${{ secrets.EC2_SSH_KEY }} | ||
| source: "dist/*" | ||
| target: "/tmp/fe-deploy" | ||
| strip_components: 1 | ||
|
|
||
| - name: Move files and set permissions | ||
| uses: appleboy/ssh-action@v1.2.0 | ||
| with: | ||
| host: ${{ secrets.EC2_HOST }} | ||
| username: ${{ secrets.EC2_USER }} | ||
| key: ${{ secrets.EC2_SSH_KEY }} | ||
| script: | | ||
| sudo mkdir -p /tmp/fe-deploy | ||
| sudo chown -R www-data:www-data /tmp/fe-deploy | ||
| sudo chmod -R 755 /tmp/fe-deploy | ||
| sudo rm -rf /var/www/dokdok-old | ||
| sudo mv /var/www/dokdok /var/www/dokdok-old | ||
| sudo mv /tmp/fe-deploy /var/www/dokdok | ||
| sudo rm -rf /var/www/dokdok-old | ||
|
Comment on lines
+52
to
+59
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. 첫 배포 시 스크립트 실패 가능 문제: Line 57에서 🔧 수정 제안 sudo mkdir -p /tmp/fe-deploy
sudo chown -R www-data:www-data /tmp/fe-deploy
sudo chmod -R 755 /tmp/fe-deploy
sudo rm -rf /var/www/dokdok-old
- sudo mv /var/www/dokdok /var/www/dokdok-old
+ sudo mv /var/www/dokdok /var/www/dokdok-old || true
sudo mv /tmp/fe-deploy /var/www/dokdok
sudo rm -rf /var/www/dokdok-old🤖 Prompt for AI Agents |
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ssh-action host key verification fingerprint known_hosts💡 Result:
appleboy/ssh-actionandappleboy/scp-actiondon’t use aknown_hostsinput; instead, they support SSH host key verification via a SHA256 host fingerprint (andproxy_fingerprintfor jump hosts). [1][2]How to do host key verification (recommended):
Get the server’s host-key fingerprint (SHA256) on the server (example for ed25519):
(Use the matching host key type your server actually uses.) [1]
Store that output as a GitHub Secret, e.g.
SSH_FINGERPRINT.Pass it to the action:
ssh-action
[1]
scp-action
[2]
If you specifically need
known_hosts-style pinning, you’d typically do that with OpenSSH directly (e.g.,ssh-keyscanto write~/.ssh/known_hosts) and then runscp/sshyourself—but for theseappleboy/*actions, the built-in mechanism is thefingerprintinput. [1][2]SSH 호스트 키 검증 누락
문제: SCP/SSH 단계에서 호스트 키 검증이 설정되지 않았습니다.
영향: 중간자 공격(MITM)에 취약합니다.
대안: 서버의 SSH 호스트 키 지문(SHA256)을 구한 후
fingerprint입력값으로 전달하세요.SSH 호스트 지문 확인:
ssh-keygen -l -f /etc/ssh/ssh_host_ed25519_key.pub | cut -d ' ' -f2🤖 Prompt for AI Agents