Skip to content

mode 4

mode 4 #14

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Run tests
run: |
pytest --cov=./ --cov-report=xml
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
build:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Google Auth
id: 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 ${{ secrets.GCP_REGION }}-docker.pkg.dev
- name: Build and Push Docker Image
run: |
docker build -t europe-west12-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/telegram-bot/telegram-bot-service:${{ github.sha }} ./telegram_bot_service
gcloud auth configure-docker europe-west12-docker.pkg.dev
docker push europe-west12-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/telegram-bot/telegram-bot-service:${{ github.sha }}
- name: Check kubectl
run: |
which kubectl
kubectl version --client
- name: Install gke-gcloud-auth-plugin
run: |
sudo apt-get update
sudo apt-get install google-cloud-sdk-gke-gcloud-auth-plugin
- name: Deploy to GKE
env:
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }}
GITHUB_SHA: ${{ github.sha }}
run: |
gcloud container clusters get-credentials ${{ secrets.GKE_CLUSTER }} --region ${{ secrets.GKE_ZONE }}
sed -i "s/\${PROJECT_ID}/$PROJECT_ID/g" k8s/telegram-bot/deployment.yaml
sed -i "s/\${GITHUB_SHA}/$GITHUB_SHA/g" k8s/telegram-bot/deployment.yaml
kubectl apply -f k8s/telegram-bot/
kubectl apply -f k8s/translation-service/
kubectl apply -f k8s/transport-service/