feat(CD): add CD pipeline workflow
This commit is contained in:
34
.github/workflows/deploy.yml
vendored
Normal file
34
.github/workflows/deploy.yml
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
name: Deploy to Server
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main # or 'master', or your preferred branch for deployment
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest # The runner environment for this job
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4 # Action to checkout your repository code
|
||||
|
||||
- name: Set up SSH
|
||||
uses: webfactory/ssh-agent@v0.9.0 # Action to set up SSH agent
|
||||
with:
|
||||
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} # Your server's SSH private key
|
||||
|
||||
- name: Add Server to Known Hosts
|
||||
run: |
|
||||
mkdir -p ~/.ssh
|
||||
ssh-keyscan -H your_server_ip >> ~/.ssh/known_hosts # Replace with your server's IP
|
||||
chmod 600 ~/.ssh/known_hosts
|
||||
|
||||
- name: Deploy via SSH
|
||||
run: |
|
||||
ssh -i ~/.ssh/id_rsa -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_SERVER }} << 'EOF'
|
||||
cd ~/cover-letter # Replace with your project's path on the server
|
||||
git pull origin main # or your branch
|
||||
docker compose down
|
||||
docker compose up -d --build
|
||||
EOF
|
||||
Reference in New Issue
Block a user