Skip to content

feat(chartvalidator): helm is now pinned to v3.19 (#9) #19

feat(chartvalidator): helm is now pinned to v3.19 (#9)

feat(chartvalidator): helm is now pinned to v3.19 (#9) #19

Workflow file for this run

name: Build and Push All Builders
on:
workflow_dispatch:
push:
branches:
- main
pull_request:
branches:
- main
env:
REGISTRY: ghcr.io
jobs:
validate-commits:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Validate conventional commits
run: |
cd .tooling
# In pull_request events, GitHub creates a merge commit.
# We want to validate the actual last commit from the PR branch, not the merge commit.
if [ "${{ github.event_name }}" = "pull_request" ]; then
# Get the HEAD SHA of the PR branch (not the merge commit)
COMMIT_SHA="${{ github.event.pull_request.head.sha }}"
echo "Validating PR commit: $COMMIT_SHA"
COMMIT_MSG=$(git log -1 --format=%s $COMMIT_SHA)
echo "Commit message: $COMMIT_MSG"
node validate-commits.js --message "$COMMIT_MSG"
else
# For push events, validate the last commit normally
echo "Validating last commit on push"
node validate-commits.js
fi
detect-changes:
needs: validate-commits
runs-on: ubuntu-latest
outputs:
changed-folders: ${{ steps.changes.outputs.changed-folders }}
has-changes: ${{ steps.changes.outputs.has-changes }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Detect changed folders
id: changes
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
BASE_REF: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.event.before }}
run: |
cd .tooling
# Run the detection script
changed_folders=$(node detect-changes.js detect)
# Convert to JSON array for matrix and set outputs
if [[ -n "$changed_folders" ]] && [[ "$changed_folders" != "[]" ]]; then
echo "changed-folders=$changed_folders" >> $GITHUB_OUTPUT
echo "has-changes=true" >> $GITHUB_OUTPUT
echo "Folders to build: $changed_folders"
else
echo "changed-folders=[]" >> $GITHUB_OUTPUT
echo "has-changes=false" >> $GITHUB_OUTPUT
echo "No folders to build"
fi
build-and-push:
needs: detect-changes
if: needs.detect-changes.outputs.has-changes == 'true'
runs-on: ubuntu-latest
strategy:
matrix:
folder: ${{ fromJson(needs.detect-changes.outputs.changed-folders) }}
fail-fast: false
permissions:
contents: read
packages: write
id-token: write
attestations: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Log in to Container Registry
uses: docker/login-action@v3
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Determine version and tags
id: version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd .tooling
# Get latest commit message for this folder
COMMIT_MSG=$(git log -1 --format=%s -- "../${{ matrix.folder }}")
echo "Commit message: $COMMIT_MSG"
# Calculate next version
IMAGE_NAME="interledger/builders/${{ matrix.folder }}"
# Determine version (this will fetch from registry or create initial)
echo "Calculating version for $IMAGE_NAME..."
VERSION_OUTPUT=$(node version-calculator.js "$IMAGE_NAME" "$COMMIT_MSG" 2>&1)
echo "$VERSION_OUTPUT"
# Extract version from output (look for "Next:" line)
NEXT_VERSION=$(echo "$VERSION_OUTPUT" | grep "Next:" | awk '{print $2}')
if [ -z "$NEXT_VERSION" ]; then
echo "Could not determine version, using v0.1.0"
NEXT_VERSION="v0.1.0"
fi
echo "next-version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "Calculated version: $NEXT_VERSION"
# Generate all tags using docker-tags module
echo "Generating tags..."
TAG_OUTPUT=$(node docker-tags.js generate "$NEXT_VERSION")
echo "$TAG_OUTPUT"
# Parse JSON output to get individual tags
FULL_TAG=$(echo "$TAG_OUTPUT" | jq -r '.full')
MINOR_TAG=$(echo "$TAG_OUTPUT" | jq -r '.minor')
MAJOR_TAG=$(echo "$TAG_OUTPUT" | jq -r '.major')
echo "full-tag=$FULL_TAG" >> $GITHUB_OUTPUT
echo "minor-tag=$MINOR_TAG" >> $GITHUB_OUTPUT
echo "major-tag=$MAJOR_TAG" >> $GITHUB_OUTPUT
echo "Tags: $FULL_TAG, $MINOR_TAG, $MAJOR_TAG, latest"
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/interledger/builders/${{ matrix.folder }}
tags: |
type=raw,value=${{ steps.version.outputs.full-tag }}
type=raw,value=${{ steps.version.outputs.minor-tag }}
type=raw,value=${{ steps.version.outputs.major-tag }}
type=raw,value=latest
labels: |
org.opencontainers.image.description=Builder tool: ${{ matrix.folder }}
org.opencontainers.image.vendor=Interledger Foundation
org.opencontainers.image.version=${{ steps.version.outputs.next-version }}
- name: Build Docker image
uses: docker/build-push-action@v5
with:
context: ./${{ matrix.folder }}
push: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
load: true
- name: Push Docker image
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
uses: docker/build-push-action@v5
with:
context: ./${{ matrix.folder }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}