ci: use Docker socket for direct build and deploy
This commit is contained in:
@@ -8,49 +8,11 @@ on:
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: self-hosted
|
||||
env:
|
||||
SSHPASS: ${{ secrets.HOST_SSH_PASS }}
|
||||
steps:
|
||||
- name: Install SSH tools
|
||||
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
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Build and redeploy
|
||||
run: |
|
||||
sshpass -e ssh vps <<'ENDSSH'
|
||||
set -e
|
||||
REPO=/home/achmad/services/kotobane
|
||||
|
||||
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
|
||||
docker compose build kotobane
|
||||
docker compose up -d --no-deps kotobane
|
||||
docker image prune -f
|
||||
|
||||
Reference in New Issue
Block a user