Skip to content

PORT transport 8000 to 8080 #30

PORT transport 8000 to 8080

PORT transport 8000 to 8080 #30

Workflow file for this run

name: Deploy to Google Cloud Run
on:
push:
branches:
- main
env:
# Transport Service
TRANSPORT_SERVICE_DATABASE_URL: ${{ secrets.TRANSPORT_SERVICE_DATABASE_URL }}
TRANSPORT_SERVICE_PORT: 8080
TRANSPORT_SERVICE_LOG_LEVEL: INFO
# Translation Service
TRANSLATION_SERVICE_DATABASE_URL: ${{ secrets.TRANSLATION_SERVICE_DATABASE_URL }}
TRANSLATION_SERVICE_PORT: 8080
TRANSLATION_SERVICE_LOG_LEVEL: INFO
TRANSLATION_SERVICE_SUPPORTED_LANGUAGES: '{"en":"English","ru":"Русский","uk":"Українська","de":"Deutsch","fr":"Français","es":"Español","it":"Italiano"}'
# Telegram Bot Service
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TRANSPORT_SERVICE_URL: ${{ secrets.TRANSPORT_SERVICE_URL }}
TELEGRAM_BOT_DATABASE_URL: ${{ secrets.TELEGRAM_BOT_DATABASE_URL }}
TELEGRAM_BOT_SUPPORTED_LANGUAGES: '{"en":"English","ru":"Русский","uk":"Українська","de":"Deutsch","fr":"Français","es":"Español","it":"Italiano"}'
TELEGRAM_BOT_LOG_LEVEL: INFO
GCP_REGION: ${{ secrets.GCP_REGION }}
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GKE_CLUSTER: ${{ secrets.GKE_CLUSTER_NAME }}
GKE_ZONE: ${{ secrets.GKE_ZONE }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest
pip install python-dotenv
pip install -r requirements.txt
pip install pytest pytest-cov
# Тестирование всех сервисов
- name: Run Tests
run: |
# Запуск тестов для каждого сервиса
cd transport_service && pytest
cd ../translation_service && pytest
cd ../telegram_bot_service && pytest
# Авторизация в Google Cloud
- name: Google Cloud Auth
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v2
- name: Configure Docker
run: |
gcloud auth configure-docker ${{ env.GCP_REGION }}-docker.pkg.dev
# Сборка и публикация Docker-образов для каждого сервиса
- name: Build and Push Transport Service
run: |
cd transport_service
docker build -t europe-west12-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/transport-service/service:${{ github.sha }} .
gcloud auth configure-docker europe-west12-docker.pkg.dev
docker push europe-west12-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/transport-service/service:${{ github.sha }}
- name: Build and Push Translation Service
run: |
cd translation_service
docker build -t europe-west12-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/translation-service/service:${{ github.sha }} .
gcloud auth configure-docker europe-west12-docker.pkg.dev
docker push europe-west12-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/translation-service/service:${{ github.sha }}
- name: Build and Push Telegram Bot Service
run: |
cd telegram_bot_service
docker build -t europe-west12-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/telegram-bot/service:${{ github.sha }} .
gcloud auth configure-docker europe-west12-docker.pkg.dev
docker push europe-west12-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/telegram-bot/service:${{ github.sha }}
# Деплой в Cloud Run (если применимо)
- name: Deploy to Cloud Run Transport Service
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GITHUB_SHA: ${{ github.sha }}
TRANSPORT_SERVICE_URL: ${{ secrets.TRANSPORT_SERVICE_URL }}
DATABASE_URL: ${{ secrets.TRANSPORT_SERVICE_DATABASE_URL }}
run: |
gcloud run deploy transport-service \
--image europe-west12-docker.pkg.dev/$PROJECT_ID/transport-service/service:$GITHUB_SHA \
--platform managed \
--region europe-west12 \
--service-account=923903653655-compute@developer.gserviceaccount.com \
--allow-unauthenticated \
--set-env-vars "TRANSPORT_SERVICE_URL=$TRANSPORT_SERVICE_URL,DATABASE_URL=$DATABASE_URL"
- name: Deploy to Cloud Run Translation Service
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GITHUB_SHA: ${{ github.sha }}
TRANSLATION_SERVICE_URL: ${{ secrets.TRANSLATION_SERVICE_URL }}
DATABASE_URL: ${{ secrets.TRANSLATION_SERVICE_DATABASE_URL }}
run: |
gcloud run deploy translation-service \
--image europe-west12-docker.pkg.dev/$PROJECT_ID/translation-service/service:$GITHUB_SHA \
--platform managed \
--region europe-west12 \
--service-account=923903653655-compute@developer.gserviceaccount.com \
--allow-unauthenticated \
--set-env-vars "DATABASE_URL=$DATABASE_URL"
- name: Deploy to Cloud Run Telegram Bot Service
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GITHUB_SHA: ${{ github.sha }}
TELEGRAM_BOT_SERVICE_URL: ${{ secrets.TELEGRAM_BOT_SERVICE_URL }}
DATABASE_URL: ${{ secrets.TELEGRAM_BOT_SERVICE_DATABASE_URL }}
TRANSPORT_SERVICE_URL: ${{ secrets.TRANSPORT_SERVICE_URL }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
run: |
gcloud run deploy telegram-bot \
--image europe-west12-docker.pkg.dev/$PROJECT_ID/telegram-bot/service:$GITHUB_SHA \
--platform managed \
--region europe-west12 \
--service-account=923903653655-compute@developer.gserviceaccount.com \
--allow-unauthenticated \
--set-env-vars "TRANSPORT_SERVICE_URL=$TRANSPORT_SERVICE_URL,DATABASE_URL=$DATABASE_URL,TELEGRAM_BOT_TOKEN=$TELEGRAM_BOT_TOKEN"