Add CD workflow

This commit is contained in:
András Schmelczer 2020-07-10 19:27:46 +02:00 committed by schmelczerandras
parent f3e91c888b
commit e35c3e5ca7
2 changed files with 26 additions and 11 deletions

View file

@ -1,21 +1,36 @@
name: Deploy notebooks name: Deploy everything
on: on:
push: push:
branches: branches:
- master - master
jobs: jobs:
docker-deploy: deploying:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout current branch with lfs - name: Checkout current branch with lfs
uses: actions/checkout@master uses: actions/checkout@master
with: with:
lfs: true lfs: true
- name: Publish notebooks to docker hub
uses: elgohr/Publish-Docker-Github-Action@master - name: Build frontend
with: run: |
name: schmelczera/declared-frontend docker build . -t declared-frontend
username: ${{ secrets.DOCKER_USERNAME }} docker save -o declared-frontend.image declared-frontend
password: ${{ secrets.DOCKER_PASSWORD }} working-directory: frontend
dockerfile: frontend/Dockerfile
tags: "latest" - name: Create id file
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > id
chmod 700 id
- name: Push artifacts
run: |
scp -i id -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null frontend/declared-frontend.image root@decla.red:/root/images/declared-frontend.image
scp -i id -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -r infrastructure root@decla.red:/root/infra
- name: Compose up
run: |
ssh -i id -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null root@decla.red 'docker load < /root/images/declared-frontend.image && \
cd /root/infra && docker-compose up -d'
rm id

View file

@ -13,7 +13,7 @@ services:
- ./data/certbot/conf:/etc/letsencrypt - ./data/certbot/conf:/etc/letsencrypt
- ./data/certbot/www:/var/www/certbot - ./data/certbot/www:/var/www/certbot
frontend: frontend:
image: schmelczera/declared-frontend image: declared-frontend
restart: unless-stopped restart: unless-stopped
certbot: certbot:
image: certbot/certbot image: certbot/certbot