
이 GitHub 작업을 통해 웹 사이트 배포 등을 자동화하십시오. 무료입니다!
Your_Project/.github/workflows/main.yml 에 다음을 배치하십시오
on : push
name : Publish Website
jobs :
web-deploy :
name : Deploy Website Every Commit
runs-on : ubuntu-latest
steps :
- name : ? Get Latest Code
uses : actions/checkout@v3
- name : Sync Files
uses : SamKirkland/web-deploy@v1
with :
target-server : example.com
remote-user : username
private-ssh-key : ${{ secrets.SSH_KEY }}
destination-path : ~/destinationFolder/Actions 탭을 선택하십시오Blank workflow file 선택하거나 Set up a workflow yourself .이 옵션이 수동으로 표시되지 않으면 YAML 파일을 수동으로 만듭니다 Your_Project/.github/workflows/main.ymlsecrets 섹션에 열쇠를 추가해야합니다. secret 추가하려면 프로젝트의 Settings 탭으로 이동 한 다음 Secrets 선택하십시오. private-ssh-key 에 대한 새로운 Secret 추가하십시오 키는 .yml 구성 파일에 직접 추가하거나 프로젝트 Secrets 스토리지에서 참조 할 수 있습니다.
secret 추가하려면 프로젝트의 Settings 탭으로 이동 한 다음 Secrets 선택하십시오. 나는 당신이 당신의 private-ssh-key 비밀로 보관하는 것이 좋습니다.
| 키 이름 | 필수의? | 예 | 기본 | 설명 |
|---|---|---|---|---|
target-server | 예 | example.com | 배포 할 대상 서버 | |
destination-path | 예 | ~/folderOnServerThatAlreadyExists/ | 배포 할 서버의 경로. 이미 존재해야합니다. | |
remote-user | 예 | username | SSH 사용자로 로그인 할 수 있습니다 | |
private-ssh-key | 예 | -----BEGIN RSA PRIVATE KEY----- ...... | SSH 개인 키. 비밀로 지정해야합니다. | |
source-path | 아니요 | ./myFolderToPublish/ | ./ | 서버에서 업로드하는 경로, 후행 슬래시로 끝나야합니다 / |
ssh-port | 아니요 | 12345 | 22 | 사용할 SSH 포트. 대부분의 호스트는 이것을 기본값에서 변경합니다. 이것은 귀하의 웹 사이트 포트가 아닙니다. |
rsync-options | 아니요 | 아래 rsync-options 섹션을 참조하십시오 | --archive --verbose --compress --human-readable --progress --delete-after --exclude=.git* --exclude=.git/ --exclude=README.md --exclude=readme.md --exclude=.gitignore | 참고 : 사용자 정의하는 경우 기본값을 다시 지정해야합니다 (원하는 것으로 가정). 맞춤형 RSYNC 인수,이 필드는 RSYNC 스크립트로 직접 전달됩니다. |
rsync-options 사용한 고급 옵션사용자 정의 인수,이 필드는 RSYNC 스크립트로 직접 전달됩니다. 모든 옵션은 RSYNC 설명서를 참조하십시오. 원하는만큼 많은 인수를 사용할 수 있으며 공간으로 분리 할 수 있습니다.
아래는 일반적으로 사용되는 Args의 불완전한 목록입니다.
| 옵션 | 설명 |
|---|---|
--archive | 재귀를 원하고 거의 모든 것을 보존하고 싶다고 말하는 빠른 방법 |
--dry-run | 아무것도 업로드하거나 삭제하지 않지만 실제 배포 인 경우 업로드/삭제할 내용을 알려줍니다. |
--stats | 파일 전송에 대한 정점 통계를 인쇄하여 데이터에 RSYNC의 Delta-Transfer 알고리즘이 얼마나 효과적인지 알 수 있습니다. |
--links | Symlinks가 발생하면 목적지에서 Symlink를 재현하십시오. |
--compress | 대상 머신으로 전송 될 때 파일 데이터를 압축하여 전송중인 데이터의 양이 줄어 듭니다. |
--human-readable | 보다 인간이 읽을 수있는 형식의 출력 바이트 (K, M, G) |
--itemize-changes | 속성 변경을 포함하여 각 파일에 대한 변경 사항의 항목 별 목록 |
--delete-after | GitHub에서 파일을 삭제하면 서버에서도 삭제됩니다. 가동 중지 시간을 최소화하기 위해 배포 종료시 파일이 삭제됩니다. |
--max-size '200K' | 이 제한을 통해 파일 동기화를 무시하십시오. 값은 "k", "m"또는 "g"가 이어지는 숫자입니다. |
--exclude 'file.txt' | 배포에서 파일을 제외합니다. Glob Pattterns (예 : *.jpg )를 지원합니다. 당신은 다중 제외를 가질 수 있습니다! |
--include 'file.txt' | 제외 된 경우에도 파일을 포함합니다. Glob Pattterns (예 : *.jpg )를 지원합니다. 당신은 여러 개의 포함을 가질 수 있습니다! |
모든 옵션은 RSYNC 설명서를 참조하십시오
'빌드'라는 NPM 스크립트가 있는지 확인하십시오. 이 구성은 대부분의 노드 구축 된 웹 사이트에서 작동해야합니다.
on : push
name : Publish Website
jobs :
web-deploy :
name : Deploy Website Every Commit
runs-on : ubuntu-latest
steps :
- name : ? Get Latest Code
uses : actions/checkout@v3
- name : ? Install Packages
- uses : actions/setup-node@v3
with :
node-version : 18
cache : " npm "
- run : npm ci
- name : ? Build
run : npm run build
- name : Sync Files
uses : SamKirkland/web-deploy@v1
with :
target-server : example.com
remote-user : username
private-ssh-key : ${{ secrets.SSH_KEY }}
destination-path : ~/destinationFolder/ 실제 변경없이 소스를 동기화하도록 작성/수정 될 파일 목록을 푸트
on : push
name : Publish Website Dry Run
jobs :
web-deploy :
name : Deploy Website Every Commit
runs-on : ubuntu-latest
steps :
- name : ? Get Latest Code
uses : actions/checkout@v3
- name : Sync Files
uses : SamKirkland/web-deploy@v1
with :
target-server : example.com
remote-user : username
private-ssh-key : ${{ secrets.SSH_KEY }}
ssh-port : 22
destination-path : ~/destinationFolder/
rsync-options : --dry-run --archive --verbose --compress --delete-after --human-readable --exclude=.git* --exclude=.git/ --exclude=README.md --exclude=readme.md --exclude=.gitignore또 다른 예를 원하십니까? GitHub 문제를 만들어 알려주십시오
이 github 액션에 감사한다면 아래의 배지 중 하나를 제공하거나 과시하십시오. 텍스트 나 색상을 자유롭게 편집하십시오.
[ < img alt = " Deployed with web deploy " src = " https://img.shields.io/badge/Deployed With-web deploy-%3CCOLOR%3E?style=for-the-badge&color=0077b6 " > ] ( https://github.com/SamKirkland/web-deploy ) [ < img alt = " Deployed with web deploy " src = " https://img.shields.io/badge/Deployed With-web deploy-%3CCOLOR%3E?style=for-the-badge&color=2b9348 " > ] ( https://github.com/SamKirkland/web-deploy ) [ < img alt = " Deployed with web deploy " src = " https://img.shields.io/badge/Deployed With-web deploy-%3CCOLOR%3E?style=for-the-badge&color=d00000 " > ] ( https://github.com/SamKirkland/web-deploy ) [ < img alt = " Website Deployed for Free with web deploy " src = " https://img.shields.io/badge/Website deployed for free with-web deploy-%3CCOLOR%3E?style=for-the-badge&color=297FA9 " > ] ( https://github.com/SamKirkland/web-deploy ) [ < img alt = " Website Deployed for Free with web deploy " src = " https://img.shields.io/badge/Website deployed for free with-web deploy-%3CCOLOR%3E?style=for-the-badge&color=2b9348 " > ] ( https://github.com/SamKirkland/web-deploy ) [ < img alt = " Website Deployed for Free with web deploy " src = " https://img.shields.io/badge/Website deployed for free with-web deploy-%3CCOLOR%3E?style=for-the-badge&color=d00000 " > ] ( https://github.com/SamKirkland/web-deploy ) GIT 파일은 기본적으로 제외됩니다
사용자 정의 된 rsync-options 있는 경우 --exclude=.git* --exclude=.git/ --exclude=README.md --exclude=readme.md --exclude=.gitignore 사용하여 기본값 제외 옵션을 다시 추가해야합니다.
rsync-options 사용하고 원하는만큼 옵션을 --exclude 수 있습니다. 기본적 으로이 작업은 GitHub 파일을 제외합니다. rsync-options 사용자 정의하기로 선택한 경우 기본값에 대해 복사하십시오.
모든 .jpg 파일 제외 예 :
rsync-options: --exclude "*.jpg"
특정 폴더 제외 예 :
rsync-options: --exclude "wp-content/themes/"
이 라이브러리는 rsync 사용하여 파일을 동기화합니다. 스크립트는 동작을 실행하는 컴퓨터에서 rsync 감지 할 수 없었습니다. runs-on: ubuntu-latest 사용하는 경우 항상 rsync 가 있습니다.
windows-latest windows-XXXX web-deploy macos-12 macos-latest
이것은 매우 쉽습니다!
windows Runners에서는 Windows 특정 단계를 실행 한 다음 ubuntu-latest 단계를 사용하여 배포하십시오.
자체 호스팅 러너에서는 web-deploy 단계 전에 rsync를 설치합니다.
runs-on : [self-hosted, linux, my-self-hosted-runner-label]
steps :
- name : Install rsync
run : |
sudo apt-get update
sudo apt-get install rsync macos 러너에서 web-deploy 단계 전에 rsync를 설치하십시오.
runs-on : macos-latest
steps :
- name : Install rsync
run : |
brew update
brew install rsync러너 사용자 정의에 대해 자세히 알아보십시오
https://docs.github.com/en/actions/using-github-hosted-runners/customizing-github-hosted-runners