--- 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 RSA_KEY: from_secret: rsa_key RSA_PUB_KEY: from_secret: rsa_pub_key privileged: false volumes: - name: jekyll path: /srv/jekyll commands: # general vm information for debugging - whoami - pwd - ls -al - git --version && git status # add dependencies to tmp vm machine - apt-get update && apt-get -y install rsync # setup Jekyll permissions and build jekyll site - adduser --no-create-home --disabled-password 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 # write the ssh key to disk for rsync handshake to remote server - mkdir -p /root/.ssh/ && touch /root/.ssh/id_rsa && touch /root/.ssh/id_rsa.pub - echo -n "$RSA_KEY" > /root/.ssh/id_rsa - echo -n "$RSA_PUB_KEY" > /root/.ssh/id_rsa.pub - cp /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys - chmod 600 /root/.ssh/id_rsa && chmod 600 /root/.ssh/id_rsa.pub - ls -al /root/.ssh/ && ls / - eval `ssh-agent -s` #- ssh-add /root/.ssh/id_rsa # add git.sharpetronics.com to known hosts - touch /root/.ssh/known_hosts - chmod 600 /root/.ssh/known_hosts #- ssh-keyscan -H git.sharpetronics.com > /etc/ssh/ssh_known_hosts 2> /dev/null # sync files to remote server [local _site ] to [remote _site www] - rsync -aXvPzr ../_site --rsh="ssh -i /root/.ssh/id_rsa" $SSH_USER@$SSH_HOST:/var/www/demo.sharpetronics.com # 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