Skip to content

Try

Try #14

Workflow file for this run

name: deploy
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_KEY }}
name: id_rsa # optional
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
if_key_exists: fail # replace / ignore / fail; optional (defaults to fail)
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.HOST }} >> ~/.ssh/known_hosts
- name: rsync over ssh
run: rsync -avz ${{ github.workspace }} ${{ secrets.SSH_USER }}@${{ secrets.HOST }}:/root/
- name: Restart containers
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
docker stop ${{ vars.DOCKER_IMAGE_NAME }} 2> /dev/null || true
docker build -t ${{ vars.DOCKER_IMAGE_NAME }} -f ./${{ github.event.repository.name }}/${{ github.event.repository.name }}/Dockerfile ./${{ github.event.repository.name }}/
docker run --name ${{ vars.DOCKER_IMAGE_NAME }} -v ./${{ github.event.repository.name }}/${{ github.event.repository.name }}/wwwroot/:/app/wwwroot/ -p 5374:80 ${{ vars.DOCKER_IMAGE_NAME }}