Spaces:
Running
Running
| name: CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - master | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| environment: Testing | |
| services: | |
| postgres: | |
| image: postgres:15 | |
| env: | |
| POSTGRES_USER: postgres | |
| POSTGRES_PASSWORD: postgres | |
| POSTGRES_DB: job_tracker_test | |
| ports: | |
| - 5432:5432 | |
| options: >- | |
| --health-cmd pg_isready | |
| --health-interval 10s | |
| --health-timeout 5s | |
| --health-retries 5 | |
| env: | |
| DATABASE_HOSTNAME: localhost | |
| DATABASE_PORT: 5432 | |
| DATABASE_PASSWORD: postgres | |
| DATABASE_NAME: job_tracker_test | |
| DATABASE_USERNAME: postgres | |
| SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
| ALGORITHM: HS256 | |
| ACCESS_TOKEN_EXPIRE_MINUTES: 30 | |
| GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.11" | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Install pytest | |
| run: pip install pytest pytest-asyncio httpx | |
| - name: Run tests | |
| run: python -m pytest --disable-warnings -v | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| environment: Deploy | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check HF_TOKEN | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| if [ -z "$HF_TOKEN" ]; then | |
| echo "HF_TOKEN is EMPTY" | |
| exit 1 | |
| else | |
| echo "HF_TOKEN is present, length: ${#HF_TOKEN}" | |
| fi | |
| - name: Push to Hugging Face | |
| env: | |
| HF_TOKEN: ${{ secrets.HF_TOKEN }} | |
| run: | | |
| git config --global user.email "ci@github.com" | |
| git config --global user.name "GitHub Actions" | |
| git config --global credential.helper store | |
| echo "https://abdullah090809:${HF_TOKEN}@huggingface.co" > ~/.git-credentials | |
| git push https://huggingface.co/spaces/abdullah090809/Job_Tracker_API HEAD:main --force | |