Skip to content

Test CI/CD Railway V.1.24 #209

Test CI/CD Railway V.1.24

Test CI/CD Railway V.1.24 #209

name: OC Lettings apps CI/CD Master
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
build_and_test:
runs-on: ubuntu-22.04
strategy:
matrix:
python-version: ["3.10"]
steps:
- name: Checkout code
uses: actions/checkout@v3
- 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
- name: Run linting
run: flake8
- name: Run tests with pytest
env:
SECRET_KEY: ${{ secrets.DJANGO_SECRET_KEY }}
DEBUG: 0
run: pytest
- name: Run Django tests
run: python manage.py test
- name: Run tests with coverage
run: |
coverage run --omit=*/tests.py manage.py test
- name: Check test coverage
run: coverage report --fail-under=80
build_and_push_to_dockerhub:
needs: build_and_test
runs-on: ubuntu-22.04
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log into Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Docker image
run: |
docker buildx build --load --file Dockerfile --tag bubhux/bubhux-oc-image-build:${{ github.sha }} --tag bubhux/bubhux-oc-image-build:latest .
docker push bubhux/bubhux-oc-image-build:${{ github.sha }}
docker push bubhux/bubhux-oc-image-build:latest
deploy_to_railway:
needs: build_and_push_to_dockerhub
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Install Railway CLI via npm
run: npm install -g @railway/cli
- name: Deploy to Railway
env:
RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}
RAILWAY_SERVICE_ID: ${{ secrets.RAILWAY_SERVICE_ID }}
RAILWAY_PROJECT_ID: ${{ secrets.RAILWAY_PROJECT_ID }}
run: railway up --service=$RAILWAY_SERVICE_ID