윈도우즈의 경우 ppk파일을 pem파일로 변환하여 사용
pem파일로 변환은 PuTTYgen을 실행시켜 기존 ppk파일을 로드한 후
상단의 Conversions 메뉴에 Export Open SSH key를 선택
파일명.pem으로 저장
Github로 가서 자동배포를 설정할 repository의 설정(Settings)으로 들어가서
Security > Secrets and variables > Actions > New repository secret
SSH로 접속할때 사용했던 호스트네임, 키, 유저정보를 각각 입력하여 생성한다
호스트네임은 AWS 퍼블릭 IPv4 주소
키 정보는 pem파일을 드래그해 열어 복사 후 입력
유저 정보는 ec2-user를 입력한다
정보들을 저장 후 repository의 Actions으로 들어가서
set up a workflow yourself, 아래 코드를 입력하여 생성
들여쓰기(Tab) 중요
key, host, username의 ${{ }} 안에 위에서 저장한 정보의 이름 기입
script: | 아래의 cd Github/streamlit_car_price/ => 해당 파일로 이동하라는 명령
name: deploy
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches:
- main
jobs:
SSH:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: ssh to ec2
uses: appleboy/ssh-action@master
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
host: ${{ secrets.HOST }}
username: ${{ secrets.USER }}
script: |
cd Github/streamlit_car_price/
git pull