Skip to content

echo-go

echo-go #30

Workflow file for this run

name: echo-go
# Go counterpart of the Rust echo workflow. Same auto-discovery on
# schedule — every upstream envoy release >= MIN_VERSION that doesn't
# yet have a :echo-go-* tag at ghcr is built.
on:
schedule:
- cron: "21 3 * * *" # 03:21 UTC, after echo
push:
branches: [main]
paths:
- echo-go/**
- echo-go-build.sh
- .github/workflows/echo-go.yaml
pull_request:
paths:
- echo-go/**
- echo-go-build.sh
- .github/workflows/echo-go.yaml
workflow_dispatch:
inputs:
envoy_version:
description: 'Specific envoy version (e.g. v1.38.0); leave blank to auto-discover'
required: false
default: ''
env:
MIN_VERSION: '1.38.0'
SOURCE_DATE_EPOCH: '0'
jobs:
plan:
name: Plan versions
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.plan.outputs.versions }}
do_push: ${{ steps.plan.outputs.do_push }}
steps:
- uses: actions/checkout@v4
- uses: imjasonh/setup-crane@v0.4
- id: plan
env:
EVENT: ${{ github.event_name }}
FORCE_VERSION: ${{ github.event.inputs.envoy_version }}
run: |
set -euo pipefail
ver_ge() { [ "$1" = "$2" ] && return 0; printf '%s\n%s\n' "$2" "$1" | sort -V -C; }
default_version=$(grep -E '^ARG ENVOY_VERSION=' echo-go/Dockerfile | head -1 | cut -d= -f2)
case "$EVENT" in
schedule)
upstream=$(crane ls docker.io/envoyproxy/envoy)
existing=$(crane ls ghcr.io/yolean/envoy 2>/dev/null || true)
missing=()
while IFS= read -r tag; do
[[ "$tag" =~ ^v([0-9]+\.[0-9]+\.[0-9]+)$ ]] || continue
ver="${BASH_REMATCH[1]}"
ver_ge "$ver" "$MIN_VERSION" || continue
if ! grep -Fxq "echo-go-$tag" <<<"$existing"; then
missing+=("$tag")
fi
done <<<"$upstream"
json=$(printf '%s\n' "${missing[@]:-}" | python3 -c 'import sys,json; print(json.dumps([l for l in sys.stdin.read().split() if l]))')
echo "versions=$json" >> "$GITHUB_OUTPUT"
echo "do_push=true" >> "$GITHUB_OUTPUT"
echo "schedule discovered missing: ${missing[*]:-<none>}"
;;
workflow_dispatch)
v="${FORCE_VERSION:-$default_version}"
echo "versions=[\"$v\"]" >> "$GITHUB_OUTPUT"
echo "do_push=true" >> "$GITHUB_OUTPUT"
;;
push)
echo "versions=[\"$default_version\"]" >> "$GITHUB_OUTPUT"
echo "do_push=true" >> "$GITHUB_OUTPUT"
;;
pull_request)
echo "versions=[\"$default_version\"]" >> "$GITHUB_OUTPUT"
echo "do_push=false" >> "$GITHUB_OUTPUT"
;;
esac
build:
name: Build ${{ matrix.version }}
needs: plan
if: ${{ needs.plan.outputs.versions != '[]' }}
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
fail-fast: false
matrix:
version: ${{ fromJSON(needs.plan.outputs.versions) }}
env:
ENVOY_VERSION: ${{ matrix.version }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build, verify, push (PUSH=${{ needs.plan.outputs.do_push }})
env:
PUSH: ${{ needs.plan.outputs.do_push }}
run: ./echo-go-build.sh