ci: use Docker socket for direct build and deploy
This commit is contained in:
@@ -8,49 +8,11 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
deploy:
|
deploy:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
env:
|
|
||||||
SSHPASS: ${{ secrets.HOST_SSH_PASS }}
|
|
||||||
steps:
|
steps:
|
||||||
- name: Install SSH tools
|
- uses: actions/checkout@v3
|
||||||
run: |
|
|
||||||
if command -v apt-get > /dev/null; then
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
apt-get update -qq
|
|
||||||
apt-get install -y -qq openssh-client sshpass
|
|
||||||
elif command -v apk > /dev/null; then
|
|
||||||
apk add --no-cache openssh-client sshpass
|
|
||||||
else
|
|
||||||
echo "ERROR: No supported package manager found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup SSH
|
|
||||||
run: |
|
|
||||||
mkdir -p ~/.ssh
|
|
||||||
chmod 700 ~/.ssh
|
|
||||||
ssh-keyscan -H "${{ secrets.HOST_IP }}" >> ~/.ssh/known_hosts
|
|
||||||
cat > ~/.ssh/config << 'EOF'
|
|
||||||
Host vps
|
|
||||||
HostName ${{ secrets.HOST_IP }}
|
|
||||||
User ${{ secrets.HOST_USER }}
|
|
||||||
StrictHostKeyChecking yes
|
|
||||||
EOF
|
|
||||||
chmod 600 ~/.ssh/config
|
|
||||||
|
|
||||||
- name: Build and redeploy
|
- name: Build and redeploy
|
||||||
run: |
|
run: |
|
||||||
sshpass -e ssh vps <<'ENDSSH'
|
docker compose build kotobane
|
||||||
set -e
|
docker compose up -d --no-deps kotobane
|
||||||
REPO=/home/achmad/services/kotobane
|
docker image prune -f
|
||||||
|
|
||||||
cd "$REPO"
|
|
||||||
git fetch origin --prune
|
|
||||||
git reset --hard
|
|
||||||
git clean -fd
|
|
||||||
git checkout main
|
|
||||||
git reset --hard origin/main
|
|
||||||
|
|
||||||
docker compose build kotobane
|
|
||||||
docker compose up -d --no-deps kotobane
|
|
||||||
docker image prune -f
|
|
||||||
ENDSSH
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
services:
|
services:
|
||||||
kotobane:
|
kotobane:
|
||||||
image: registry.achmad.dev/kotobane:latest
|
build: .
|
||||||
container_name: kotobane
|
container_name: kotobane
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
ports:
|
||||||
|
|||||||
Reference in New Issue
Block a user