Skip to content

CI

CI #282

Workflow file for this run

name: CI
on:
schedule:
# https://crontab.guru/#20_3_*_*_2,5
- cron: '20 3 * * 2,5'
push:
branches-ignore:
- "gh-pages"
workflow_dispatch:
inputs:
pr:
description: 'Pull Request number'
required: true
type: string
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v3
with:
python-version: "3.12"
- id: pip-cache
uses: actions/cache@v3
with:
path: .venv
key: ${{ runner.os }}-pip-v2-${{ hashFiles('**/runtime.txt') }}-${{ hashFiles('**/requirements.txt') }}
- if: steps.pip-cache.outputs.cache-hit != 'true'
run: python -m venv .venv && source .venv/bin/activate && pip install -r requirements.txt
- if: "${{ github.event.inputs.pr == '' }}"
run: source .venv/bin/activate && pip install -e git+https://github.com/django/django.git@main#egg=django
- if: "${{ github.event.inputs.pr != '' }}"
run: source .venv/bin/activate && pip install -e git+https://github.com/django/django.git@refs/pull/${{ inputs.pr }}/head#egg=django
- run: source .venv/bin/activate && ./manage.py makemigrations --check
- run: source .venv/bin/activate && ./manage.py migrate --noinput
- run: source .venv/bin/activate && ./manage.py runserver &
- run: source .venv/bin/activate && ./manage.py collectstatic --noinput
- run: ./snapshot/backup.sh || true
- run: cp -R ./static/* ./django_admin_tests/django_admin_tests/v5.1/english/static
- uses: actions/configure-pages@v4
- uses: actions/upload-pages-artifact@v3
with:
path: django_admin_tests/django_admin_tests
- uses: actions/upload-artifact@v4
with:
name: snapshot
path: django_admin_tests/django_admin_tests
retention-days: 1
- if: "${{ github.event.inputs.pr == '' }}"
uses: JamesIves/github-pages-deploy-action@v4.4.3
with:
branch: gh-pages
folder: django_admin_tests
clean: true
- if: "${{ github.event.inputs.pr != '' }}"
uses: JamesIves/github-pages-deploy-action@v4.4.3
with:
branch: preview-${{ inputs.pr }}
folder: django_admin_tests
clean: true
deploy:
needs: build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- uses: actions/deploy-pages@v4