Skip to content

CICD: Depoly docker container #3

CICD: Depoly docker container

CICD: Depoly docker container #3

Workflow file for this run

name: ci
on:
push:
branches:
- cicd
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.8
-
name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v2
with:
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/python-ci:latest
-
name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/python-ci:latest
docker run -d -p 5000:5000 ${{ secrets.DOCKERHUB_USERNAME }}/python-ci:latest