Skip to content
Latchkey

Build latest IANA data workflow (moment/moment-timezone)

The Build latest IANA data workflow from moment/moment-timezone, explained and optimized by Latchkey.

B

CI health: B - good

Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: moment/moment-timezone.github/workflows/build-data.ymlLicense MITView source

What it does

This is the Build latest IANA data workflow from the moment/moment-timezone repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Build latest IANA data

on:
  workflow_dispatch:

jobs:
  build-data:
    name: Fetch and build latest data from IANA
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: lts/*
          cache: npm

      - name: Install dependencies
        run: npm ci

      # This differs slightly from the default `grunt data` flow. We want to explicitly compile
      # `zic` and `zdump` to avoid relying on whatever version is on the action runners.
      - name: Download tzdata and tzcode
        run: |
          npx grunt --verbose clean data-download
          npx grunt --verbose data-download --fetch-tzcode

      - name: Build zic and zdump
        run: |
          pushd temp/download/latest
          make clean
          make
          popd

      - name: Generate new data
        run: |
          npx grunt --verbose data-meta \
            data-zic --zic-path=./temp/download/latest/zic \
            data-zdump --zdump-path=./temp/download/latest/zdump \
            data-collect \
            data-dedupe \
            data-pack \
            data-tests

      # The PR-specific workflow doesn't seem to run for PRs created by other workflows,
      # so we run the tests manually here just in case
      - name: Run tests
        run: npm test
        # Create a PR even if tests fail, so the branch can be pulled down locally to debug errors
        continue-on-error: true

      # Prepare version metadata for use in PR creation
      - name: Prepare metadata
        id: meta
        run: |
          echo "TZDATA_VERSION=$(cat temp/download/latest/version)" >> "$GITHUB_OUTPUT"
          echo -e "This contains the following changes from tzdb (edit this to remove details irrelevant to this project):\n\n\`\`\`" > temp/pr-body.txt
          awk '/^Release [[:digit:]]{4}/ {\
              if (used != 1) { used = 1; active = 1 }\
              else { active = 0 }\
            } { if (active == 1) print }' \
            temp/download/latest/NEWS >> temp/pr-body.txt
          echo "\`\`\`" >> temp/pr-body.txt

      - name: Create pull request
        uses: peter-evans/create-pull-request@v6
        with:
          author: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>'
          branch: automated/data-update
          commit-message: 'data: Add ${{ steps.meta.outputs.TZDATA_VERSION }}'
          title: 'data: Add ${{ steps.meta.outputs.TZDATA_VERSION }}'
          body-path: temp/pr-body.txt
          reviewers: ${{ github.actor }}

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Build latest IANA data
 
on:
  workflow_dispatch:
 
jobs:
  build-data:
    timeout-minutes: 30
    name: Fetch and build latest data from IANA
    runs-on: latchkey-small
 
    steps:
      - uses: actions/checkout@v4
 
      - name: Use Node.js
        uses: actions/setup-node@v4
        with:
          node-version: lts/*
          cache: npm
 
      - name: Install dependencies
        run: npm ci
 
      # This differs slightly from the default `grunt data` flow. We want to explicitly compile
      # `zic` and `zdump` to avoid relying on whatever version is on the action runners.
      - name: Download tzdata and tzcode
        run: |
          npx grunt --verbose clean data-download
          npx grunt --verbose data-download --fetch-tzcode
 
      - name: Build zic and zdump
        run: |
          pushd temp/download/latest
          make clean
          make
          popd
 
      - name: Generate new data
        run: |
          npx grunt --verbose data-meta \
            data-zic --zic-path=./temp/download/latest/zic \
            data-zdump --zdump-path=./temp/download/latest/zdump \
            data-collect \
            data-dedupe \
            data-pack \
            data-tests
 
      # The PR-specific workflow doesn't seem to run for PRs created by other workflows,
      # so we run the tests manually here just in case
      - name: Run tests
        run: npm test
        # Create a PR even if tests fail, so the branch can be pulled down locally to debug errors
        continue-on-error: true
 
      # Prepare version metadata for use in PR creation
      - name: Prepare metadata
        id: meta
        run: |
          echo "TZDATA_VERSION=$(cat temp/download/latest/version)" >> "$GITHUB_OUTPUT"
          echo -e "This contains the following changes from tzdb (edit this to remove details irrelevant to this project):\n\n\`\`\`" > temp/pr-body.txt
          awk '/^Release [[:digit:]]{4}/ {\
              if (used != 1) { used = 1; active = 1 }\
              else { active = 0 }\
            } { if (active == 1) print }' \
            temp/download/latest/NEWS >> temp/pr-body.txt
          echo "\`\`\`" >> temp/pr-body.txt
 
      - name: Create pull request
        uses: peter-evans/create-pull-request@v6
        with:
          author: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>'
          branch: automated/data-update
          commit-message: 'data: Add ${{ steps.meta.outputs.TZDATA_VERSION }}'
          title: 'data: Add ${{ steps.meta.outputs.TZDATA_VERSION }}'
          body-path: temp/pr-body.txt
          reviewers: ${{ github.actor }}
 

What changed

1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

What Latchkey heals here

This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:

This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow