hello calltouch #112
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: Build and deploy Docker container | |
on: | |
push: | |
branches: | |
- master | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Login to DockerHub Registry | |
run: echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
- name: Build the tagged Docker image | |
run: docker build . --file Dockerfile --tag korneevm/learnpython | |
- name: Push the tagged Docker image | |
run: docker push korneevm/learnpython | |
- name: login to server and pull container | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
port: ${{ secrets.PORT }} | |
script_stop: true | |
script: | | |
cd /opt/servers | |
docker-compose pull learnpython | |
docker-compose up -d | |
docker exec -i servers_learnpython_1 python3 manage.py migrate --noinput | |
docker exec -i servers_learnpython_1 python3 manage.py collectstatic --noinput |