Merge remote-tracking branch 'origin/master' #32
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: Docker Image CI | |
on: | |
push: | |
branches: [master] | |
pull_request: | |
branches: [master] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Login to Docker Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: registry.sberan.dev | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: registry.sberan.dev/portfolio:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: executing remote ssh commands using password | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.SERVER_IP }} | |
username: ${{ secrets.SERVER_USERNAME }} | |
password: ${{ secrets.SERVER_PASSWORD }} | |
script: | | |
echo "${{ secrets.REGISTRY_PASSWORD }}" | docker login ${{ secrets.REGISTRY_LINK }} -u "${{ secrets.REGISTRY_USERNAME }}" --password-stdin | |
docker pull ${{ secrets.REGISTRY_LINK }}/portfolio:latest | |
docker stop portfolio | |
docker rm portfolio | |
docker run -d --name portfolio -p 4250:4250 -v /home/sberan/portfolio/data:/app/data --env DATABASE_URL="${{ secrets.DATABASE_URL }}" ${{ secrets.REGISTRY_LINK }}/portfolio:latest |