Testactions #21
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: Test Production | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
test-production: | |
runs-on: ubuntu-latest | |
env: | |
db_name: ${{ secrets.DB_NAME }} | |
MONGO_URI_NAACP: ${{ secrets.MONGO_URI_NAACP }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.9' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r ./se_ml_production/ML_backend_GKE/ML_GKE/ML_Service_GKE/requirements.txt | |
- name: Google Auth | |
id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS }} | |
- name: Run deployment | |
id: deployment | |
run: | | |
python ./se_ml_production/ML_backend_GKE/ML_GKE/ML_Service_GKE/main.py | |
# Get the PID of the background process | |
APP_PID=$! | |
# Monitor the deployment log for the success message | |
while true; do | |
if grep -q "Deployment Test Complete with no errors" ./deployment.log; then | |
echo "Deployment Test Complete with no errors" | |
kill $APP_PID | |
exit 0 | |
fi | |
sleep 1 | |
done | |
# If the loop exits, it means the deployment failed | |
echo "Deployment Test Failed" | |
kill $APP_PID | |
exit 1 | |