Try #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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_CONTAINER_NAME }} 2> /dev/null || true | |
docker rm ${{ vars.DOCKER_CONTAINER_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 -d --name ${{ vars.DOCKER_CONTAINER_NAME }} -v ./${{ github.event.repository.name }}/${{ github.event.repository.name }}/wwwroot/:/app/wwwroot/ -v ./${{ github.event.repository.name }}/${{ github.event.repository.name }}/App_Data/:/app/App_Data/ -p 5374:80 ${{ vars.DOCKER_IMAGE_NAME }} |