Fix "Check for Changes in Static Files" in web.yml #2376
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: Python package | |
on: | |
push: | |
branches: | |
- master | |
- dev | |
pull_request: | |
jobs: | |
django: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python: | |
# - 3.6 | |
- "3.10" | |
django: | |
# - "==2.2.*" | |
- "==4.2.*" | |
steps: | |
- uses: actions/checkout@v4 | |
# Pull the latest image to build, and avoid caching pull-only images. | |
# (docker pull is faster than caching in most cases.) | |
- run: | | |
docker compose --file docker-compose.yml --file docker-compose.test.yml pull | |
docker pull python:${{matrix.python}}-slim | |
- name: Start database early | |
run: docker compose up -d db | |
- name: Build application | |
run: make build | |
env: | |
PYTHON_VERSION: ${{ matrix.python }} | |
- name: Migration check | |
run: make check | |
- name: Show settings | |
run: make settings | |
- name: Regenerate frontend with gulp service | |
run: | | |
docker compose -f docker-compose.yml run web python manage.py collectstatic --no-input | |
docker compose -f docker-compose.yml up gulp | |
- name: Check for Changes in Static Files | |
run: | | |
if ! git diff --quiet poradnia/static/; then | |
echo "Static files updated. Preparing to commit changes." | |
# Configure Git user for committing changes | |
git config --global user.name "GitHub Actions" | |
git config --global user.email "actions@github.com" | |
# Stage and commit the changes | |
git add poradnia/static/ | |
git commit -m "Update static files after dependency change" | |
# Fetch the latest remote changes for the base branch | |
echo "Fetching latest changes for the base branch..." | |
git fetch origin | |
# Rebase onto the base branch to ensure the branch is up-to-date | |
echo "Rebasing changes onto the base branch..." | |
git rebase origin/${{ github.event.pull_request.base.ref }} || { | |
echo "Rebase failed. Please resolve conflicts manually."; | |
git rebase --abort; | |
exit 1; | |
} | |
# Push the changes back to the branch with safety | |
echo "Pushing changes back to the branch..." | |
git push --force-with-lease origin HEAD:${{ github.event.pull_request.head.ref }} || { | |
echo "Push failed. Ensure no conflicts or simultaneous pushes occurred."; | |
exit 1; | |
} | |
echo "Static files changes have been successfully pushed." | |
else | |
echo "No changes in static files." | |
fi | |
- name: Run unit tests | |
run: make test | |
- name: Run e2e tests | |
run: make e2e | |
docs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- run: docker compose pull | |
- name: Build application | |
run: make build | |
- name: Build documentation | |
run: make docs |