sharpetronics.com/.drone.yml

105 lines
2.7 KiB
YAML
Raw Normal View History

2022-05-08 16:00:37 -04:00
---
kind: pipeline
type: docker
2022-05-08 19:21:48 -04:00
name: build
2022-05-08 16:00:37 -04:00
2022-05-08 16:26:06 -04:00
workspace:
path: /drone/src
platform:
2022-05-08 16:37:33 -04:00
os: linux
2022-05-08 16:26:06 -04:00
arch: amd64
2022-05-08 17:34:25 -04:00
trigger:
branch:
- master
2022-05-08 16:12:12 -04:00
steps:
2022-05-08 18:10:41 -04:00
- name: build-website
2022-05-09 19:45:25 -04:00
image: ruby:latest
environment:
2022-05-09 19:27:53 -04:00
GITEA_USER:
from_secret: gitea_user
2022-05-09 19:27:53 -04:00
GITEA_PASS:
from_secret: gitea_pass
2022-05-09 19:27:53 -04:00
SSH_USER:
from_secret: ssh_user
SSH_HOST:
from_secret: ssh_host
RSA_KEY:
from_secret: rsa_key
2022-05-09 20:45:59 -04:00
RSA_PUB_KEY:
from_secret: rsa_pub_key
2022-05-10 00:13:15 -04:00
SERVER_PASS:
from_secret: server_pass
2022-05-08 18:38:31 -04:00
privileged: false
2022-05-08 16:26:06 -04:00
volumes:
- name: jekyll
path: /srv/jekyll
2022-05-08 18:10:41 -04:00
2022-05-08 16:12:12 -04:00
commands:
2022-05-09 19:27:53 -04:00
# general vm information for debugging
2022-05-08 18:43:35 -04:00
- whoami
- pwd
2022-05-08 18:44:55 -04:00
- ls -al
2022-05-09 23:08:21 -04:00
- getent passwd
2022-05-10 16:27:09 -04:00
- git --version && git status
2022-05-09 19:27:53 -04:00
2022-05-09 19:30:12 -04:00
# add dependencies to tmp vm machine
2022-05-10 18:14:01 -04:00
- apt-get update && apt-get -y install rsync sshpass
2022-05-09 19:27:53 -04:00
# write the ssh key to disk for rsync handshake to remote server
2022-05-10 18:24:59 -04:00
- mkdir -p ~/.ssh/
- chmod 700 ~/.ssh
2022-05-10 18:27:21 -04:00
#- touch ~/.ssh/id_rsync_ed25519
2022-05-10 18:26:39 -04:00
#- touch ~/.ssh/id_rsync_ed25519.pub
2022-05-10 18:16:23 -04:00
- ssh-keygen -t ed25519 -f ~/.ssh/id_rsync_ed25519 -N ''
2022-05-10 18:29:02 -04:00
- cat ~/.ssh/id_rsync_ed25519
2022-05-10 18:36:20 -04:00
- cat ~/.ssh/id_rsync_ed25519.pub
2022-05-10 18:27:53 -04:00
- chmod 600 ~/.ssh/id_rsync_ed25519
2022-05-10 18:38:28 -04:00
- eval `ssh-agent -s`
- SSHPASS=$SSHPASS sshpass -e ssh-copy-id odinzu@45.33.119.101
2022-05-10 15:55:02 -04:00
#- touch ~/password.txt
#- echo -n $SERVER_PASS > ~/password.txt
#- echo $SERVER_PASS
#- cat ~/password.txt
2022-05-10 18:14:01 -04:00
-
2022-05-10 15:55:02 -04:00
2022-05-10 18:15:17 -04:00
2022-05-10 16:44:49 -04:00
#- cat "$RSA_KEY" >> "~/.ssh/id_rsa" <
2022-05-10 18:14:01 -04:00
#- echo cat $RSA_KEY >> ~/.ssh/id_rsa
2022-05-10 16:44:49 -04:00
#- cat "$RSA_PUB_KEY" >> ~/.ssh/id_rsa.pub
2022-05-10 18:14:01 -04:00
#- echo cat $RSA_PUB_KEY >> ~/.ssh/id_rsa.pub
2022-05-10 18:15:17 -04:00
2022-05-10 18:14:01 -04:00
#- ssh-add
2022-05-09 23:56:22 -04:00
#- cp /root/.ssh/id_rsa.pub ~/.ssh/authorized_keys
2022-05-10 00:23:01 -04:00
#- ls -al /root/.ssh/
2022-05-10 00:24:49 -04:00
# 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
2022-05-10 00:27:05 -04:00
# prepare _site dir
- ls -a _site/
- rm _site/docker-compose.yml
2022-05-10 00:23:01 -04:00
# 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
2022-05-09 19:27:53 -04:00
# sync files to remote server [local _site ] to [remote _site www]
2022-05-10 18:24:59 -04:00
- rsync -aXvPzr -e ssh ../_site/* odinzu@45.33.119.101:/var/www/demo.sharpetronics.com/html/
2022-05-09 19:27:53 -04:00
# create tar.gz of _site directory for download elsewhere
- tar -czf ../www-data.tar.gz ../_site/*
- ls ../ww*
2022-05-09 19:27:53 -04:00
# TBC... add download of files from download.sharpetronics.com