swagger3 #65
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: Django CI | |
on: | |
push: | |
branches: [ "Refactoring" ] | |
pull_request: | |
branches: [ "Refactoring" ] | |
jobs: | |
# Build Job | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.8, 3.9] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install drf-yasg | |
working-directory: ./CargoHub | |
# Test Job- | |
test: | |
runs-on: self-hosted | |
needs: build | |
strategy: | |
matrix: | |
python-version: [3.8, 3.9] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install drf-yasg | |
pip install requests | |
working-directory: ./CargoHub | |
- name: Test server connectivity | |
run: curl -v http://145.24.223.64/api/v1/clients/ | |
- name: Test with pytest | |
run: | | |
pytest | |
working-directory: ./CargoHub | |
# Check SSH Key Availability | |
check_ssh: | |
runs-on: [self-hosted, linux, x64] | |
steps: | |
- name: Debug SSH Key Secret | |
run: | | |
echo "Checking if the SERVER_SSH_KEY secret is available" | |
echo "Secret is set" | |
env: | |
SERVER_SSH_KEY: ${{ secrets.SERVER_SSH_KEY }} | |
# Deploy Job | |
deploy: | |
runs-on: [self-hosted, Linux, X64] | |
needs: test | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Setup SSH agent and use the SSH key from GitHub secrets | |
- name: Set up SSH agent | |
uses: webfactory/ssh-agent@v0.5.3 | |
with: | |
ssh-private-key: ${{ secrets.SERVER_SSH_KEY }} | |
- name: SSH into server and deploy | |
run: | | |
ssh -o StrictHostKeyChecking=no ${{ | |
secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} << 'EOF' | |
cd /home/ubuntu-1021342/Repo/Process-and-Tools/CargoHub | |
git pull origin Refactoring | |
source /home/ubuntu-1021342/Repo/Process-and-Tools/CargoHub/venv/bin/activate | |
pip install -r requirements.txt | |
pip install drf-yasg | |
python manage.py migrate | |
sudo systemctl restart django | |
EOF | |
timeout-minutes: 10 | |