728x90
반응형
SMALL
GitHub Action
GitHub Action은 빌드, 테스트 및 배포 파이프라인을 자동화할 수 있는 지속적 통합 및 지속적 배포 (CI/CD) 플랫폼이다.
secrets 설정
Github Action을 사용하여 ssh 접속할 때, 민감한 정보나 환경 설정들을 직접 코드에 포함시키지 않고 안전하게 workflow에서 사용할 수 있게 secrets을 설정한다.
secrets는 다음과 같이 추가한다.
|
Github Actions Workflow 작성
로컬 환경에서 Github 레포지토리에 push한 commit을 EC2에서 확인할 수 있도록 워크플로우인 yml파일을 작성한다.
# deployec2.yml
name: deploy to EC2
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: deploy to EC2
uses: appleboy/ssh-action@master # ssh 접속 오픈 소스
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd /home/ubuntu/airflow # git pull을 실행할 EC2상의 경로를 작성
git pull
레포지토리에 .github/workflows 디렉토리가 생긴 것을 확인할 수 있다.
Amazon EC2에서 확인
#1. 변경사항 pull 받기 (workflow 파일)
git pull origin main
#2. 로컬 환경에서 yml 파일이 생겼는지 확인
ls -al .github/workflows
#3. workflow를 테스트하기 위해 임의의 파일 생성
vim githubactions.txt
#4. git add
git add githubactions.txt
#5. git commit
git commit -m "test actions"
#6. git push
git push origin main
workflow가 문제 없이 작동했으면 다음과 같은 화면을 볼 수 있다.
https://docs.github.com/en/actions
GitHub Actions documentation - GitHub Docs
Automate, customize, and execute your software development workflows right in your repository with GitHub Actions. You can discover, create, and share actions to perform any job you'd like, including CI/CD, and combine actions in a completely customized wo
docs.github.com
728x90
반응형
LIST
'App Programming > Git' 카테고리의 다른 글
[Git] github remote: Permission to 403 (0) | 2023.11.27 |
---|---|
[Git] gitignore 설정 (0) | 2023.01.08 |
[Git] 원격 브랜치 가져오기 (0) | 2022.12.29 |
[Git] error: Pulling is not possible because you have unmerged files (0) | 2022.12.22 |
[Git] (non-fast-forward) git error: failed to push some refs to (0) | 2022.12.09 |