GitHub Actions를 사용하여 VPS에서 웹 사이트의 지속적인 배포를 설정하는 방법
Doesn't matter if it is a private or public repository
전제 조건
이 자습서에 필요한 전제 조건은 다음과 같습니다.
이 튜토리얼에서 다룰 내용 중 일부입니다.
1단계 - 터미널을 열고 VPS에 ssh를 추가합니다.
$ ssh user@hostname
$ cd ~/.ssh
2단계 - ssh 키 생성
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
3단계: Enter 키를 반복해서 눌러 기본 이름 설정(암호를 설정하지 않음)
4단계 - authorized_keys에 공개 키 추가
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
5단계 - GitHub 비밀 생성
$ cat ~/.ssh/id_rsa

구성하려는 GitHub 리포지토리로 이동하고 설정 탭을 클릭한 다음 옵션 메뉴에서 다음 비밀을 클릭하고 추가합니다.

아직 여기 계시다면 축하합니다! 우리는 거의 끝났습니다!
With the steps above completed, we’re left with only a single step more, namely, our .github/workflows/deploy.yml file.
6단계 - 프라이빗/퍼블릭 리포지토리를 자동 배포하도록 GitHub 작업 구성
머신에 로컬로 복제된 리포지토리가 있다고 가정하고 .github/workflows 폴더를 만들고 그 안에 deploy.yml 파일을 만듭니다.
name: Deploy
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Copy repository contents via scp
uses: appleboy/scp-action@master
env:
HOST: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.SSHKEY }}
with:
source: "."
target: "/var/www/mywebsite"
- name: Executing remote command
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
USERNAME: ${{ secrets.USERNAME }}
PORT: ${{ secrets.PORT }}
KEY: ${{ secrets.SSHKEY }}
script: ls
Notice that my remote command is just " ls ".if you are trying to auto deploy a React App or a Vue App, you could set your script command to Build command.
진실의 순간!
deploy.yml 변경 사항을 커밋하고 리포지토리에 푸시합니다.
오류 없이 빌드하고 VPS로 푸시해야 합니다.
$ git add .
$ git commit -m "deploy"
$ git push origin master
GitHub 리포지토리로 이동하여 작업 메뉴를 클릭하면 다음을 볼 수 있습니다.

Yay ! That's it, your repository is officially configured, now everytime you make changes and push to GitHub that action will run and auto deploy your website.
읽어 주셔서 감사합니다!
귀하의 의견을 환영합니다
Reference
이 문제에 관하여(GitHub Actions를 사용하여 VPS에서 웹 사이트의 지속적인 배포를 설정하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/knowbee/how-to-setup-continuous-deployment-of-a-website-on-a-vps-using-github-actions-54im텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)