github action #4
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 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
Production: | |
name: Deploy to DigitalOcean | |
runs-on: ubuntu-latest | |
environment: Production | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Build & Deploy | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
SSH_HOST: ${{secrets.SSH_HOST}} | |
USER_NAME: ${{secrets.USER_NAME}} | |
run: | | |
echo "Deploying to EC2" | |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > private_key && chmod 600 private_key | |
ssh -o StrictHostKeyChecking=no -i private_key ${{ secrets.USER_NAME }}@${{ secrets.SSH_HOST }} ' | |
cd /root/learning-journey-yt && | |
git reset --hard && | |
git checkout main && | |
git pull origin main && | |
docker-compose down && | |
docker-compose rm -fsv && | |
docker-compose up --build -d | |
' |