Skip to content

Commit 5e2d99b

Browse files
committed
build: implement depoy action
1 parent 274d909 commit 5e2d99b

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/deploy.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Deploy to Kali
2+
run-name: ${{ github.actor }} is deploying to Kali...
3+
4+
on:
5+
workflow_dispatch:
6+
release:
7+
types: [published]
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Trigger remote Git checkout and deploy
14+
uses: appleboy/ssh-action@v1
15+
with:
16+
host: ${{ secrets.SSH_HOST }}
17+
username: ${{ secrets.SSH_USER }}
18+
key: ${{ secrets.SSH_KEY }}
19+
script: |
20+
set -e
21+
22+
[email protected]:Facts-and-Files/nginx-proxy.g
23+
TARGET_DIR=~/nginx-proxy
24+
25+
echo "Checking repo at $TARGET_DIR..."
26+
if [ -d "$TARGET_DIR/.git" ]; then
27+
echo "Repository exists. Pulling latest changes..."
28+
git -C "$TARGET_DIR" fetch --all
29+
git -C "$TARGET_DIR" reset --hard origin/main
30+
else
31+
echo "Repository not found. Cloning..."
32+
git clone "$REPO_URL" "$TARGET_DIR"
33+
fi
34+
35+
echo "Populating .env file for Docker Compose..."
36+
cat <<EOF > $TARGET_DIR/.env
37+
DEFAULT_EMAIL=${{ secrets.DEFAULT_EMAIL }}
38+
EOF
39+
40+
echo "Environment file written to $TARGET_DIR/.env"
41+
42+
NETWORK_NAME="kali-net"
43+
if ! docker network ls --format '{{.Name}}' | grep -q "^${NETWORK_NAME}$"; then
44+
docker network create ${NETWORK_NAME}
45+
echo "Docker network ${NETWORK_NAME} created."
46+
else
47+
echo "Docker network ${NETWORK_NAME} already exists."
48+
fi
49+
50+
echo "Docker updating service..."
51+
cd "$TARGET_DIR"
52+
docker compose pull || true
53+
docker compose up -d --no-deps nginx-proxy nginx-proxy-acme
54+
55+
echo "Deployment complete."

0 commit comments

Comments
 (0)