name: Validate on: push: pull_request: jobs: validate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" - run: python3 tools/validate.py # A change to a fact needs a new [[history]] entry (docs/schema.md), and trail-numbers.txt may # only be appended to. The check compares the work with its base, so it needs the history of # the base branch: a full clone, not the shallow one that checkout makes by default. history: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-python@v5 with: python-version: "3.12" - name: Check the history env: EVENT: ${{ github.event_name }} BASE_REF: ${{ github.base_ref }} BEFORE: ${{ github.event.before }} run: | # A pull request is checked against its target branch; a push against the commit # before it. A new branch has no such commit: the tool then uses origin/main. if [ "$EVENT" = "pull_request" ]; then base="origin/$BASE_REF" else base="$BEFORE" fi python3 tools/check_history.py --base "$base" - run: python3 -m unittest discover tools/tests -p "test_history.py" - run: python3 -m unittest discover tools/tests -p "test_trail_numbers.py" - run: python3 -m unittest discover tools/tests -p "test_season*.py" site: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: "3.12" # Standard library only: no packages to install, and no ImageMagick. # web/tools/make_thumbs.py and make_cards.py are manual tools; web/thumbs/ and # web/cards/ are committed and the build only copies them (web/olt/thumbs.py, cards.py). - run: python3 -m unittest discover -s web/tests - run: python3 web/build.py --out _site # Netlify builds the site from this repository when asked to. Asking only # after both jobs above pass means a broken record or page is never deployed. deploy: needs: [validate, history, site] if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.repository == 'swaits/longhikes' runs-on: ubuntu-latest steps: - name: Ask Netlify to build and publish main env: NETLIFY_BUILD_HOOK: ${{ secrets.NETLIFY_BUILD_HOOK }} run: curl -fsS -X POST -d '{}' "$NETLIFY_BUILD_HOOK"