Skip to content
Latchkey

Build website workflow (zloirock/core-js)

The Build website workflow from zloirock/core-js, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get run de-duplication, 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: zloirock/core-js.github/workflows/build-website.ymlLicense MITView source

What it does

This is the Build website workflow from the zloirock/core-js 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 website

on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  run-on-server:
    runs-on: ubuntu-latest

    steps:
      - name: Extract branch name
        shell: bash
        run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
        id: extract_branch

      - name: Checkout code
        uses: actions/checkout@v7
        with:
          ref: ${{ steps.extract_branch.outputs.branch }}

      - name: Copy runner file to remote server
        uses: garygrossgarten/github-action-scp@0.10.0
        with:
          local: website/scripts/runner.mjs
          remote: /var/www/core-js/runner.mjs
          host: ${{ secrets.REMOTE_HOST }}
          username: ci
          privateKey: ${{ secrets.CI_SSH_KEY }}

      - name: Copy runner wrapper file to remote server
        uses: garygrossgarten/github-action-scp@0.10.0
        with:
          local: website/scripts/runner.sh
          remote: /var/www/core-js/runner.sh
          host: ${{ secrets.REMOTE_HOST }}
          username: ci
          privateKey: ${{ secrets.CI_SSH_KEY }}

      - name: Copy runner helpers file to remote server
        uses: garygrossgarten/github-action-scp@0.10.0
        with:
          local: website/scripts/helpers.mjs
          remote: /var/www/core-js/helpers.mjs
          host: ${{ secrets.REMOTE_HOST }}
          username: ci
          privateKey: ${{ secrets.CI_SSH_KEY }}

      - name: Setup SSH
        uses: webfactory/ssh-agent@v0.10.0
        with:
          ssh-private-key: ${{ secrets.CI_SSH_KEY }}

      - name: Make runner.sh executable on remote
        run: |
          ssh -o StrictHostKeyChecking=no ci@${{ secrets.REMOTE_HOST }} "chmod +x /var/www/core-js/runner.sh"

      - name: Run node runner.mjs on remote server
        run: |
          ssh -o StrictHostKeyChecking=no ci@${{ secrets.REMOTE_HOST }} "cd /var/www/core-js/ && ./runner.sh"

The same workflow, on Latchkey

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

name: Build website
 
on:
  push:
    branches:
      - master
  workflow_dispatch:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  run-on-server:
    timeout-minutes: 30
    runs-on: latchkey-small
 
    steps:
      - name: Extract branch name
        shell: bash
        run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
        id: extract_branch
 
      - name: Checkout code
        uses: actions/checkout@v7
        with:
          ref: ${{ steps.extract_branch.outputs.branch }}
 
      - name: Copy runner file to remote server
        uses: garygrossgarten/github-action-scp@0.10.0
        with:
          local: website/scripts/runner.mjs
          remote: /var/www/core-js/runner.mjs
          host: ${{ secrets.REMOTE_HOST }}
          username: ci
          privateKey: ${{ secrets.CI_SSH_KEY }}
 
      - name: Copy runner wrapper file to remote server
        uses: garygrossgarten/github-action-scp@0.10.0
        with:
          local: website/scripts/runner.sh
          remote: /var/www/core-js/runner.sh
          host: ${{ secrets.REMOTE_HOST }}
          username: ci
          privateKey: ${{ secrets.CI_SSH_KEY }}
 
      - name: Copy runner helpers file to remote server
        uses: garygrossgarten/github-action-scp@0.10.0
        with:
          local: website/scripts/helpers.mjs
          remote: /var/www/core-js/helpers.mjs
          host: ${{ secrets.REMOTE_HOST }}
          username: ci
          privateKey: ${{ secrets.CI_SSH_KEY }}
 
      - name: Setup SSH
        uses: webfactory/ssh-agent@v0.10.0
        with:
          ssh-private-key: ${{ secrets.CI_SSH_KEY }}
 
      - name: Make runner.sh executable on remote
        run: |
          ssh -o StrictHostKeyChecking=no ci@${{ secrets.REMOTE_HOST }} "chmod +x /var/www/core-js/runner.sh"
 
      - name: Run node runner.mjs on remote server
        run: |
          ssh -o StrictHostKeyChecking=no ci@${{ secrets.REMOTE_HOST }} "cd /var/www/core-js/ && ./runner.sh"
 

What changed

2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.

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