diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..e7271fa --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,22 @@ + +name: Continuous Deployment + +on: + workflow_run: + workflows: ["Continuous Integration"] + types: + - completed + +jobs: + build: + + runs-on: self-hosted + + steps: + - name: pull Docker image + run: sudo docker pull vijayj0shi/remx_api:latest + - name: Delete Old docker container + run: sudo docker rm -f remx_api-container || true + - name: Run Docker Container + run: sudo docker run -d -p 8080:8080 --name remx_api-container vijayj0shi/remx_api + diff --git a/.github/workflows/python-app.yml b/.github/workflows/ci.yml similarity index 71% rename from .github/workflows/python-app.yml rename to .github/workflows/ci.yml index 703d639..69c5f25 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/ci.yml @@ -1,17 +1,13 @@ # This workflow will install Python dependencies, run tests and lint with a single version of Python # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python -name: Python application +name: Continuous Integration on: push: branches: [ "main" ] pull_request: branches: [ "main" ] - -permissions: - contents: read - jobs: build: @@ -34,4 +30,14 @@ jobs: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Login Dockerhub + env: + DOCKER_USERNAME: ${{secrets.DOCKERHUB_USERNAME}} + DOCKER_PASSWORD: ${{secrets.DOCKERHUB_PASSWORD}} + run: docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD + + - name: Build the Docker image + run: docker build -t vijayj0shi/remx_api:latest . + - name: push Docker image + run: docker push vijayj0shi/remx_api:latest diff --git a/.gitignore b/.gitignore index 72a343c..755d886 100644 --- a/.gitignore +++ b/.gitignore @@ -50,7 +50,7 @@ coverage.xml .hypothesis/ .pytest_cache/ cover/ -testing.py + # Translations *.mo *.pot @@ -141,6 +141,7 @@ myenv.bak/ # mkdocs documentation /site +testing.py # mypy .mypy_cache/ .dmypy.json diff --git a/testing.py b/testing.py index f223fb6..b53f309 100644 --- a/testing.py +++ b/testing.py @@ -7,12 +7,10 @@ print(model) -# path = os.path.join("tests","tst.zip") -# files =[("files", open(path, "rb"))] +path = os.path.join("tests","tst.zip") +files =[("files", open(path, "rb"))] -# response = requests.post("http://127.0.0.1:8000/api/predict/upload", files=files) +response = requests.post("http://127.0.0.1:8000/api/predict/upload", files=files) -# # Check response - -# print(response.json()) \ No newline at end of file +print(response.json()) \ No newline at end of file