feat: Modify User Reformer Model for Match IA (#14) #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to EC2 | |
on: # master 브랜치에 push될 경우만 수행 | |
push: | |
branches: | |
- main | |
jobs: # 아래의 jobs를 수행 | |
build: | |
name: Build | |
runs-on: ubuntu-latest # 여러 OS 중 우분투 환경 선택 | |
steps: | |
- name: checkout # 마스터 브랜치로 checkout | |
uses: actions/checkout@main | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Login to Amazon ECR | |
id: login-ecr | |
uses: aws-actions/amazon-ecr-login@v1 | |
- name: create remote directory # ec2 서버에 접속해 리모트 디렉토리 생성 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
script: | | |
mkdir -p /home/ubuntu/UPCY_BE | |
- name: copy source via ssh key # ssh key로 현재 푸시된 소스를 서버에 복사 (rsync로 github runners와 ec2 동기화) | |
uses: burnett01/[email protected] | |
with: | |
switches: -avzr --delete | |
remote_path: /home/ubuntu/UPCY_BE | |
remote_host: ${{ secrets.HOST }} | |
remote_user: ubuntu | |
remote_key: ${{ secrets.KEY }} | |
- name: Build, tag, and push image to Amazon ECR | |
id: build-image | |
env: | |
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
ECR_REPOSITORY: upcy | |
IMAGE_TAG: ${{ github.run_number }} | |
run: | | |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . | |
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | |
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | |
- name: executing remote ssh commands using password # 서버로 접속해 .env 파일 생성 후 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
script: | | |
echo '${{ secrets.ENV_VARS }}' >> /home/ubuntu/UPCY_BE/.env | |
- name: executing remote ssh commands using password # deploy.sh 파일 실행 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
script: | | |
sh /home/ubuntu/UPCY_BE/config/scripts/deploy.sh ${{github.run_number}} | |
- name: Log out of Amazon ECR | |
if: always() | |
run: docker logout ${{ steps.login-ecr.outputs.registry }} |