GitHub 에서 was, web 서버에 자동 빌드/배포 설정이 가능하다.
해당 프로젝트의 git 레파지토리내에 Actions 탭 New workflow 버튼을 클릭 한다.
프로젝트 루트 경로에 workflows 디렉토리가 생성되고 .yml 설정파일이 만들어진다.
[deno.yml]
코드를 # This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will install Deno and run tests across stable and nightly builds on Windows, Ubuntu and macOS.
# For more information see: https://github.com/denolib/setup-deno
name: CI
on:
push:
branches: [master]
pull_request:
branches: [master]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd 배포대상 디렉토리명
git pull https://깃토큰값@github.com/깃허브아이디/프로젝트명.git
- name: send custom message with args
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO_ID }}
token: ${{ secrets.TELEGRAM_TOKEN }}
args: ${{ github.actor }} 님 소스 웹서버 반영 완료 됐어요.
name: Deploy 부분이 GitHub 소스를 서버에 반영하기 위한 설정이다.
secrets.HOST = 배포 서버 IP
secrets.USERNAME = 서버 접속 계정명
secrets.KEY = 서버접속 인증키
secrets.PORT = 서버접속 포트번호
script: 부분은 접속후 서버에 전달할 명령어를 작성하는 부분이다.
위에서는 SSH로 서버 접속 후 소스 디렉토리 이동 git 레파지토리에서 변경된 소스를 pull 하는 방식이다.
git pull https://깃토큰값@github.com/깃허브아이디/프로젝트명.git 에서
깃토큰값은 아래 화면 Settings > Developer settings > personal access tokens 메뉴에서 토큰 생성이 가능하다.
GitHub 프로젝트 페이지내에 Settings > Secrets > New repository Secret 버튼을 통해
프로퍼티값을 설정하고 .yml 설정파일에서 참조값으로 사용할 수 있다.
여기까지 자동배포 설정은 완료이고 소스 수정 시 workflows 가 작업하는 내용이나 로그 확인은
해당 페이지에서 수행 작업별 확인이 가능하다.