Skip to content

Site Builds

Kyle Johnson edited this page Mar 28, 2021 · 12 revisions

Manual Builds

If you need to manually build the site for some reason, that has to be done from the admin console at http://netlify.com.

Automatic Builds

Differential Builds

We are employing Netlify's Gatsby caching mechanism to do differential builds, so only pages that are updated are rebuilt. That generally means a given build will only take a few of minutes.

Builds Triggered by CMS Updates

Site builds for the live site are done automatically whenever things like blog posts, distributions, featured add-ons, and store items (which are managed using a web interface) are updated.

Netlify has a bot that monitors builds. If you request a number of builds back-to-back (like editing a bunch of blog posts quickly), the bot will hold all the changes until there haven't been any for a few minutes. Then it will build everything once. So if you did a bunch of edits and are wondering why the site hasn't rebuilt yet, that's probably why. Wait a few minutes, and the system should catch up.

Builds Triggered by Updates to the Repo

Pushes to Main

Any time new updates are pushed to the kodi-tv repo's main branch, that triggers a site build at Netlify.

PRs to Main

If you fork the repo and then do a PR back to the main branch, Netlify will do a build specific for the PR. And subsequent updates to the PR will trigger a rebuild. This is a useful way to preview suggested changes before merging them.

Daily Updates of Add-on Pages

There is a scheduled GitHub action that grabs a current copy of the site code, runs the script scripts/addon-parser/app.js. The script parses the XML from the mirrors and generates json files for addons, categories, and authors for each repo it is set to run on and then pushes updated files back to the kodi-tv repo's main branch. That then triggers a site build at Netlify. That Github action is currently scheduled to run at 2am UTC. It can also be triggered manually from the Actions tab of the repo.

Editing the GitHub Action

The GitHub action is stored in the repo at .github/workflows/update-addon-history.yml. Here's the current action:

name: Update Add-on Info

on:
  workflow_dispatch:
  schedule:
    - cron:  '00 02 * * *'

defaults:
  run:
    working-directory: scripts/addon-parser

jobs:
  add-on-update:
    name: Update Add-ons
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v2

      - name: Cache addon-parser npm node nodules
        uses: actions/cache@v2
        id: nodecache
        with:
          path: |
            ~/.npm
            scripts/addon-parser/node_modules
          key: ${{ runner.os }}-node-${{ hashFiles('scripts/addon-parser/package.json') }}

      - name: Set Node Version
        uses: actions/setup-node@master
        with:
          node-version: 15.x

      - name: Install dependencies
        if: steps.nodecache.outputs.cache-hit != 'true'
        run: npm install

      - name: Run addon-parser for Leia branch
        run: node app.js --kv=leia

      - name: Run addon-parser for Matrix branch
        run: node app.js --kv=matrix

      - name: Push new files back
        uses: mikeal/publish-to-github-action@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH_NAME: 'main'

The action loads the current main branch, loads any existing caches of node_modules for the addon-parser script, installs dependencies (only if the package.json for addon-parser has changed), runs the script (one time for each branch we are monitoring), and then pushes the changed files to the main branch.