sharpetronics.com/.drone.yml

77 lines
2.0 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-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
- 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-09 19:47:30 -04:00
- apt-get update && apt-get -y install rsync
2022-05-09 19:30:12 -04:00
2022-05-09 19:27:53 -04:00
# setup Jekyll permissions and build jekyll site
2022-05-09 19:55:40 -04:00
- adduser --no-create-home --disabled-password jekyll
2022-05-08 18:59:26 -04:00
- chown -R jekyll:jekyll /drone/src
2022-05-08 16:12:12 -04:00
- gem install bundler
- bundle install
2022-05-08 17:44:47 -04:00
- bundle exec jekyll build --trace
2022-05-09 19:27:53 -04:00
# prepare _site dir
2022-05-08 18:59:26 -04:00
- ls -a _site/
2022-05-08 19:08:56 -04:00
- rm _site/docker-compose.yml
2022-05-09 19:27:53 -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 *
2022-05-09 19:27:53 -04:00
- 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
# write the ssh key to disk for rsync handshake to remote server
- mkdir -p /root/.ssh/ && touch /root/.ssh/id_rsa
- echo -n "$RSA_KEY" > /root/.ssh/id_rsa
- chmod 600 /root/.ssh/id_rsa
# sync files to remote server [local _site ] to [remote _site www]
2022-05-09 20:42:43 -04:00
- rsync -aXvPzr ../_site --rsh="ssh -i /root/.ssh/id_rsa" $SSH_USER@$SSH_HOST:/var/www/demo.sharpetronics.com
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