108 lines
2.9 KiB
YAML
108 lines
2.9 KiB
YAML
---
|
|
kind: pipeline
|
|
type: docker
|
|
name: build
|
|
|
|
workspace:
|
|
path: /drone/src
|
|
|
|
platform:
|
|
os: linux
|
|
arch: amd64
|
|
|
|
trigger:
|
|
branch:
|
|
- master
|
|
|
|
steps:
|
|
- name: build-website
|
|
image: ruby:latest
|
|
environment:
|
|
GITEA_USER:
|
|
from_secret: gitea_user
|
|
GITEA_PASS:
|
|
from_secret: gitea_pass
|
|
SSH_USER:
|
|
from_secret: ssh_user
|
|
SSH_HOST:
|
|
from_secret: ssh_host
|
|
NO_HOSTKEY:
|
|
from_secret: no_hostkey
|
|
SERVER_PASS:
|
|
from_secret: server_pass
|
|
privileged: false
|
|
volumes:
|
|
- name: jekyll
|
|
path: /srv/jekyll
|
|
|
|
commands:
|
|
# general vm information for debugging
|
|
- whoami
|
|
- pwd
|
|
- ls -al
|
|
- getent passwd
|
|
- git --version && git status
|
|
|
|
# add dependencies to tmp vm machine
|
|
- apt-get update && apt-get -y install rsync sshpass openssh-server openssh-client
|
|
# write the ssh key to disk for rsync handshake to remote server
|
|
- mkdir -p ~/.ssh/
|
|
- chmod 700 ~/.ssh
|
|
#- touch ~/.ssh/id_rsync_ed25519
|
|
#- touch ~/.ssh/id_rsync_ed25519.pub
|
|
- ssh-keygen -t ed25519 -f ~/.ssh/id_rsync_ed25519 -N ''
|
|
- cat ~/.ssh/id_rsync_ed25519
|
|
- cat ~/.ssh/id_rsync_ed25519.pub
|
|
- chmod 600 ~/.ssh/id_rsync_ed25519
|
|
- eval `ssh-agent -s`
|
|
- service ssh start
|
|
- service ssh status
|
|
- echo "$NO_HOSTKEY" > /etc/ssh/ssh_config
|
|
- cat /etc/ssh/ssh_config
|
|
- service ssh reload
|
|
- SSHPASS="$SERVER_PASS" sshpass -ev ssh-copy-id $SSH_USER@$SSH_HOST
|
|
#- touch ~/password.txt
|
|
#- echo -n $SERVER_PASS > ~/password.txt
|
|
#- echo $SERVER_PASS
|
|
#- cat ~/password.txt
|
|
-
|
|
|
|
|
|
#- cat "$RSA_KEY" >> "~/.ssh/id_rsa" <
|
|
#- echo cat $RSA_KEY >> ~/.ssh/id_rsa
|
|
#- cat "$RSA_PUB_KEY" >> ~/.ssh/id_rsa.pub
|
|
#- echo cat $RSA_PUB_KEY >> ~/.ssh/id_rsa.pub
|
|
|
|
#- ssh-add
|
|
#- cp /root/.ssh/id_rsa.pub ~/.ssh/authorized_keys
|
|
#- ls -al /root/.ssh/
|
|
|
|
# setup Jekyll permissions and build jekyll site
|
|
- adduser --no-create-home --disabled-password --gecos "" jekyll
|
|
- chown -R jekyll:jekyll /drone/src
|
|
- gem install bundler
|
|
- bundle install
|
|
- bundle exec jekyll build --trace
|
|
|
|
# prepare _site dir
|
|
- ls -a _site/
|
|
- rm _site/docker-compose.yml
|
|
|
|
# update www-data branch with fresh drone ci Jekyll _site build
|
|
- git clone https://git.sharpetronics.com/sharpetronics/sharpetronics.com.git
|
|
- cd sharpetronics.com/
|
|
- git checkout www-data
|
|
- cp -R ../_site/* .
|
|
- git add *
|
|
- git commit -m "bots beeing bots! A drone www-data push"
|
|
- git push https://$GITEA_USER:$GITEA_PASS@git.sharpetronics.com/sharpetronics/sharpetronics.com.git
|
|
|
|
# sync files to remote server [local _site ] to [remote _site www]
|
|
- rsync -aXvPzr -e ssh ../_site/* odinzu@45.33.119.101:/var/www/demo.sharpetronics.com/html/
|
|
|
|
# create tar.gz of _site directory for download elsewhere
|
|
- tar -czf ../www-data.tar.gz ../_site/*
|
|
- ls ../ww*
|
|
|
|
# TBC... add download of files from download.sharpetronics.com
|