This file contains hidden or 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
| # Fails when public_html/ is not the current build. | |
| # | |
| # Hostinger's Git deployment publishes public_html/ verbatim -- it runs no | |
| # build. So that folder is the website, and a change to my-app/ or admin/ that | |
| # does not also update it is a change that silently never reaches the server. | |
| # There is no error anywhere: the deploy succeeds, the site keeps serving the | |
| # previous build, and the only symptom is that the thing you changed is not | |
| # there. | |
| # | |
| # This makes that failure loud. It builds, compares, and fails with the list of | |
| # differing paths. It writes nothing and pushes nothing -- the fix is to run | |
| # `npm run publish:site` and commit, which is a person's decision, not this | |
| # workflow's. | |
| name: public_html is current | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| # Read-only on purpose. A workflow that could commit the fix would also be a | |
| # workflow that can push to main on its own, which is a much larger permission | |
| # than catching a stale folder is worth. | |
| permissions: | |
| contents: read | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22.x | |
| cache: npm | |
| cache-dependency-path: my-app/package-lock.json | |
| - name: Install | |
| working-directory: my-app | |
| run: npm ci | |
| - name: Build | |
| working-directory: my-app | |
| run: npm run build | |
| - name: Compare the build with what is committed | |
| run: | | |
| # The build is not byte-reproducible in one respect: index.html and | |
| # the prerendered routes embed the asset hash, which changes with the | |
| # content. That is fine -- it means a real change always shows up | |
| # here -- but it also means this must compare trees, not timestamps. | |
| if diff -r --brief my-app/dist public_html > /tmp/drift.txt 2>&1; then | |
| echo "public_html matches the build." | |
| exit 0 | |
| fi | |
| echo "::error::public_html/ is not the current build, so these changes will not reach the website." | |
| echo "" | |
| echo "Hostinger publishes public_html/ as-is and runs no build, so the" | |
| echo "site will keep serving whatever is committed there." | |
| echo "" | |
| echo "Fix it with:" | |
| echo "" | |
| echo " npm run publish:site" | |
| echo " git add public_html && git commit" | |
| echo "" | |
| echo "Differences:" | |
| sed 's/^/ /' /tmp/drift.txt | |
| exit 1 |