nightly workflow (doitintl/kube-no-trouble)
The nightly workflow from doitintl/kube-no-trouble, explained and optimized by Latchkey.
A
CI health: A - excellent
Point runs-on at Latchkey and get job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the nightly workflow from the doitintl/kube-no-trouble 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: nightly
on:
schedule:
- cron: '2 2 * * *'
jobs:
create-tag:
name: Create tag
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4.2.2
with:
fetch-depth: 0
- name: Set tag name
id: git_tag
run: echo "tag=$(git describe --tags --match '[0-9].[0-9].[0-9]')" >> "$GITHUB_OUTPUT"
- name: check if tag exists
id: tag_exists
run: |
set -x
exists=false
[ "$(git tag -l "${TAG}")" = "${TAG}" ] && exists=true
[ "$(git tag -l "nightly-${TAG}")" = "nightly-${TAG}" ] && exists=true
echo "result=${exists}" >> "$GITHUB_OUTPUT"
env:
TAG: ${{ steps.git_tag.outputs.tag }}
- name: Setup SSH Keys and known_hosts
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.GH_SSH_KEY }}"
if: ${{ steps.tag_exists.outputs.result != 'true' }}
- name: Create tag
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
TAG: "nightly-${{ steps.git_tag.outputs.tag }}"
run: |
git tag "${TAG}"
git remote set-url origin git@github.com:doitintl/kube-no-trouble.git
git push origin "refs/tags/${TAG}"
if: ${{ steps.tag_exists.outputs.result != 'true' }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: nightly on: schedule: - cron: '2 2 * * *' jobs: create-tag: timeout-minutes: 30 name: Create tag runs-on: latchkey-small steps: - name: Checkout code uses: actions/checkout@v4.2.2 with: fetch-depth: 0 - name: Set tag name id: git_tag run: echo "tag=$(git describe --tags --match '[0-9].[0-9].[0-9]')" >> "$GITHUB_OUTPUT" - name: check if tag exists id: tag_exists run: | set -x exists=false [ "$(git tag -l "${TAG}")" = "${TAG}" ] && exists=true [ "$(git tag -l "nightly-${TAG}")" = "nightly-${TAG}" ] && exists=true echo "result=${exists}" >> "$GITHUB_OUTPUT" env: TAG: ${{ steps.git_tag.outputs.tag }} - name: Setup SSH Keys and known_hosts env: SSH_AUTH_SOCK: /tmp/ssh_agent.sock run: | mkdir -p ~/.ssh ssh-keyscan github.com >> ~/.ssh/known_hosts ssh-agent -a $SSH_AUTH_SOCK > /dev/null ssh-add - <<< "${{ secrets.GH_SSH_KEY }}" if: ${{ steps.tag_exists.outputs.result != 'true' }} - name: Create tag env: SSH_AUTH_SOCK: /tmp/ssh_agent.sock TAG: "nightly-${{ steps.git_tag.outputs.tag }}" run: | git tag "${TAG}" git remote set-url origin git@github.com:doitintl/kube-no-trouble.git git push origin "refs/tags/${TAG}" if: ${{ steps.tag_exists.outputs.result != 'true' }}
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.