Design CI/CD workflows to be efficient, consistent, and purposeful across all environments. When writing or modifying pipeline scripts: 1. Batch related operations to minimize redundant commands and improve performance
Design CI/CD workflows to be efficient, consistent, and purposeful across all environments. When writing or modifying pipeline scripts:
For example, when working with Docker images, prefer batched operations:
# Inefficient: Multiple separate registry operations
for tag in $TAGS; do
docker buildx imagetools create -t "${tag}" "${image}@${DIGEST}"
done
# Efficient: Batched operations per registry
readarray -t lines < <(grep "^${image}:" <<< "$TAGS"); tags=();
for line in "${lines[@]}"; do tags+=(-t "$line"); done
docker buildx imagetools create "${tags[@]}" "${image}@${DIGEST}"
For build caching strategies, be intentional about clean vs. incremental builds:
# Explicitly using source files in cache key to ensure clean builds in release pipelines
- name: Docker Cargo caches
uses: actions/cache@v4
with:
key: docker-cargo-caches-$-$
Enter the URL of a public GitHub repository