changed dock and version #113
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: Python application | |
on: | |
push: | |
branches: [ "master" ] | |
paths-ignore: | |
- 'README.md' | |
pull_request: | |
branches: [ "master" ] | |
paths-ignore: | |
- 'README.md' | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest # Simplified to run only on ubuntu-latest for Docker compatibility | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v3 | |
with: | |
python-version: "3.8" # Specifying one Python version for simplicity | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install flake8 pytest requests | |
pip install -r requirements.txt | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: 'ritikdutta' | |
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | |
- name: Pull Docker image from Docker Hub | |
run: docker pull ritikdutta/freeapi_forked:latest | |
# Assign a custom name to the container for easy reference | |
- name: Run Docker container | |
run: | | |
docker run -d --name my_freeapi_container --env MONGODB_URI='${{ secrets.MONGO_CLIENT_URL }}' -p 8080:8080 ritikdutta/freeapi_forked:latest | |
sleep 20 | |
- name: Check API availability | |
run: | | |
curl http://localhost:8080/api/v1/healthcheck | |
- name: Add 'src' directory to PYTHONPATH | |
run: echo "PYTHONPATH=$PYTHONPATH:$(pwd)/src" >> $GITHUB_ENV | |
- name: Decode secure bundle and create file | |
run: | | |
echo "${{ secrets.SECURE_BUNDLE_BASE64 }}" | base64 -d > secure-connect-cassandra-datamigrato.zip | |
echo "Secure bundle file path: $(pwd)/secure-connect-cassandra-datamigrato.zip" | |
- name: Decode token and create file | |
run: | | |
echo "${{ secrets.TOKEN_JSON_BASE64 }}" | base64 -d > cassandra_datamigrato-token.json | |
echo "Token file path: $(pwd)/cassandra_datamigrato-token.json" | |
- name: Run Pytest | |
env: | |
MONGO_CLIENT_URL: ${{ secrets.MONGO_CLIENT_URL }} | |
run: | | |
pytest tests/test_unit.py | |
- name: Stop Docker Container | |
run: | | |
docker stop my_freeapi_container | |
- name: Remove Docker container | |
run: docker rm my_freeapi_container | |