Skip to content

added test job to deploy & testing success #23

added test job to deploy & testing success

added test job to deploy & testing success #23

Workflow file for this run

name: Deploy
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
name: run-tests
env:
TESTING: true
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.12.4"
- name: Setup Python Virtual Environment
run: python -m venv python3-virtualenv
- name: Install Dependencies
run: python3-virtualenv/bin/pip install -r requirements.txt
- name: Run Tests
run: ./run_test.sh
deploy:
name: "Deploy to VPS"
runs-on: ubuntu-latest
needs: test
steps:
- name: Configure SSH
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/deploy-key.pem
chmod 600 ~/.ssh/deploy-key.pem
cat >> ~/.ssh/config <<END
Host my-vps
HostName $SSH_IP
User $SSH_USER
IdentityFile ~/.ssh/deploy-key.pem
StrictHostKeyChecking no
END
env:
SSH_USER: ${{ secrets.SSH_USER }}
SSH_IP: ${{ secrets.SSH_IP }}
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy site
run: ssh my-vps '~/redeploy-site.sh'
- name: Send Discord Notification
run: curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=🚀 Deployment Successful"
- name: Print Container Status
run: ssh my-vps 'docker ps'
failure-notification:
name: "Notify Failure"
runs-on: ubuntu-latest
needs: [test, deploy]
if: ${{ needs.test.result == 'failure' || needs.deploy.result == 'failure' }}
steps:
- name: Send Discord Notification on Failure
run: curl -s -X POST "${{ secrets.DISCORD_WEBHOOK }}" -d "content=🚨 Deployment Failed"