Skip to content

Commit 3c347ea

Browse files
authored
Update README.md
1 parent ed22c9e commit 3c347ea

File tree

1 file changed

+114
-1
lines changed

1 file changed

+114
-1
lines changed

README.md

Lines changed: 114 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,114 @@
1-
# github-actions-ssh-git-pull
1+
# GitHub Actions SSH Docker Update Template
2+
3+
This repository provides a **GitHub Actions CI/CD template** to automatically **update and restart a Docker Compose project** on a remote server using **SSH**.
4+
5+
> 📦 Ideal for quickly deploying updates to remote Docker apps from your GitHub repository.
6+
7+
---
8+
9+
## 🚀 Features
10+
11+
- ✅ Automatic deployment on push to `main` (or any branch)
12+
- 🔐 Secure connection via SSH with secrets
13+
- 🐳 Docker Compose support (`docker compose pull` + `up -d`)
14+
- 🔁 Easy to fork and reuse across projects
15+
16+
---
17+
18+
## 📂 Project Structure
19+
20+
```
21+
.github/
22+
└── workflows/
23+
└── deploy.yml # CI/CD workflow
24+
```
25+
26+
---
27+
28+
## ⚙️ Prerequisites
29+
30+
1. Remote server with:
31+
- Docker & Docker Compose installed
32+
- Public SSH key of the GitHub Action added to `~/.ssh/authorized_keys`
33+
2. GitHub repository with:
34+
- This template forked or cloned
35+
- Required secrets added (see below)
36+
37+
---
38+
39+
## 🔐 Required GitHub Secrets
40+
41+
Go to your repo → **Settings****Secrets and variables****Actions****New repository secret** and add:
42+
43+
| Secret Name | Description |
44+
|------------------|-------------------------------------------------|
45+
| `SSH_HOST` | IP or domain of your remote server |
46+
| `SSH_USERNAME` | SSH user with access to the project directory |
47+
| `SSH_KEY` | Private SSH key (no passphrase) |
48+
| `PROJECT_PATH` | Absolute path of the Docker Compose project |
49+
50+
---
51+
52+
## 📦 GitHub Actions Workflow (`.github/workflows/deploy.yml`)
53+
54+
```yaml
55+
name: Deploy via SSH
56+
57+
on:
58+
push:
59+
branches:
60+
- main
61+
62+
jobs:
63+
deploy:
64+
runs-on: ubuntu-latest
65+
66+
steps:
67+
- name: Checkout repo
68+
uses: actions/checkout@v4
69+
70+
- name: Set up SSH
71+
uses: webfactory/ssh-agent@v0.9.0
72+
with:
73+
ssh-private-key: ${{ secrets.SSH_KEY }}
74+
75+
- name: Connect and Deploy
76+
run: |
77+
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} << 'EOF'
78+
cd ${{ secrets.PROJECT_PATH }}
79+
git pull origin main
80+
docker compose pull
81+
docker compose up -d
82+
EOF
83+
```
84+
85+
## 🚀 Quick Start
86+
87+
- Fork this repo (or copy deploy.yml to your own)
88+
- Add the required GitHub secrets
89+
- Ensure SSH access from GitHub to your remote server
90+
- Push to main branch – the deployment runs automatically!
91+
92+
## 🛠️ Customization
93+
94+
Change main to another branch in the on.push.branches section
95+
96+
Adjust the docker compose commands if your setup differs
97+
98+
Add steps for migrations, backups, health checks, etc.
99+
100+
## 🧪 Testing
101+
102+
You can manually trigger a run from GitHub:
103+
104+
Go to Actions → Deploy via SSH → Run workflow
105+
106+
## 🧾 License
107+
108+
MIT License — feel free to use and adapt.
109+
110+
## 🙋‍♂️ Author
111+
112+
Max Base (Ali)
113+
114+
🔗 GitHub: [@BaseMax](https://github.com/basemax)

0 commit comments

Comments
 (0)