diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 43474c3..ccf491c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,17 +28,19 @@ jobs: aws-region: ap-northeast-2 # Step 4: Deploy to EC2 instance - - name: Deploy to EC2 - run: | - echo "${{ secrets.EC2_SSH_KEY }}" > key.pem - chmod 600 key.pem - ssh -o StrictHostKeyChecking=no -i key.pem -t ubuntu@${{ secrets.EC2_INSTANCE_IP }} << 'EOF' - docker pull public.ecr.aws/h7p2f6d8/ticats_ai:latest - docker-compose down - docker-compose up -d - EOF - env: - DATABASE_URL: ${{ secrets.DATABASE_URL }} + - name: Deploy to server + uses: appleboy/ssh-action@master + id: deploy + with: + host: ${{ secrets.EC2_INSTANCE_IP }} + username: ubuntu + key: ${{ secrets.EC2_SSH_KEY }} + envs: | + DATABASE_URL=${{ secrets.DATABASE_URL }} + script: | + docker pull public.ecr.aws/h7p2f6d8/ticats_ai:latest + docker-compose down + docker-compose up -d # Step 5: Log in to Amazon ECR (Elastic Container Registry) - name: Login to Amazon ECR