diff --git a/.github/workflows/deploy_test.yml b/.github/workflows/deploy_test.yml new file mode 100644 index 00000000..b473b9b8 --- /dev/null +++ b/.github/workflows/deploy_test.yml @@ -0,0 +1,49 @@ +name: Squib testing + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + build: + + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v3 + with: + python-version: '3.10' + - name: Install Dependencies + run: | + python3 -m pip install --upgrade pip + pip3 install -r requirements.txt + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + + - name: Build and push Docker image + run: | + docker build -t ${{ secrets.DOCKER_USERNAME }}/squib . + docker push ${{ secrets.DOCKER_USERNAME }}/squib + + - name: Deploy to Heroku + env: + HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} + HEROKU_APP_NAME: squib + run: | + heroku container:login + heroku container:push web -a $HEROKU_APP_NAME + heroku container:release web -a $HEROKU_APP_NAME + + - name: Run Tests + env: + SECRET_KEY: ${{ secrets.SECRET_KEY }} + run: | + cd squib + python3 manage.py test diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index ec5bfc71..00000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Squib testing - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -jobs: - build: - - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v3 - with: - python-version: '3.10' - - name: Install Dependencies - run: | - python3 -m pip install --upgrade pip - pip3 install -r requirements.txt - - name: Run Tests - env: - SECRET_KEY: ${{ secrets.SECRET_KEY }} - run: | - cd squib - python3 manage.py test diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..2bd1ce39 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM python:3.10 + +WORKDIR /app + +COPY requirements.txt . + +RUN pip install --no-cache-dir virtualenv +RUN virtualenv venv + +ENV PATH="/app/venv/bin:$PATH" + +RUN pip install --no-cache-dir -r requirements.txt + +COPY . . + +EXPOSE $PORT + +CMD ["gunicorn", "squib.wsgi:application", "--bind", "0.0.0.0:$PORT"] \ No newline at end of file diff --git a/Pipfile b/Pipfile deleted file mode 100644 index e6877e52..00000000 --- a/Pipfile +++ /dev/null @@ -1,19 +0,0 @@ -[[source]] -url = "https://pypi.org/simple" -verify_ssl = true -name = "pypi" - -[packages] -asgiref = "==3.7.2" -django = "==4.2.2" -sqlparse = "==0.4.4" -websocket-client = "==1.5.2" -"djangorestframework-3.14.0" = "*" -"django-cors-headers-4.1.0" = "*" -djangorestframework = "==3.14.0" -django-cors-headers = "==4.1.0" - -[dev-packages] - -[requires] -python_version = "3.10" diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..d69e8c63 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web:gunicorn squib.wsgi:application \ No newline at end of file diff --git a/heroku.yml b/heroku.yml new file mode 100644 index 00000000..2b8f79bb --- /dev/null +++ b/heroku.yml @@ -0,0 +1,3 @@ +build: + docker: + web: Dockerfile \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index e12e8009..2746132b 100644 Binary files a/requirements.txt and b/requirements.txt differ