Feat/dynamic ebpf #51
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Verify Chart Versions | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
paths: | |
- 'charts/**/templates/**' | |
- 'charts/**/values.yaml' | |
- 'charts/**/values.schema.json' | |
on: | |
- main | |
jobs: | |
verify-and-bump: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
- name: Install yq | |
run: | | |
sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
sudo chmod +x /usr/local/bin/yq | |
- name: Check and bump versions | |
id: version_check | |
run: | | |
set -x | |
UMBRELLA_CHARTS=(k8s-integration) | |
# Function to bump patch version | |
bump_version() { | |
local version=$1 | |
local major minor patch | |
IFS='.' read -r major minor patch <<< "$version" | |
echo "$major.$minor.$((patch + 1))" | |
} | |
update_umbrella_charts() { | |
for umbrella_chart in ${UMBRELLA_CHARTS[@]}; do | |
local chart_file="charts/$umbrella_chart/Chart.yaml" | |
CURRENT_VERSION=$(yq eval '.version' "$chart_file") | |
NEW_VERSION=$(bump_version "$CURRENT_VERSION") | |
if [[ ! $CHANGED_CHARTS =~ $umbrella_chart ]]; then | |
echo "Processing Chart.yaml: $CHART_YAML" | |
CHANGED_CHARTS="$CHANGED_CHARTS $umbrella_chart" | |
yq eval ".version = \"$NEW_VERSION\"" -i "$chart_file" | |
fi | |
done | |
} | |
BASE_COMMIT_SHA=${{ github.event.pull_request.base.sha }} | |
PR_COMMIT_SHA=$(git rev-parse HEAD) | |
echo "Base SHA: BASE_COMMIT_SHA" | |
echo "Current SHA: PR_COMMIT_SHA" | |
# Get list of changed files | |
CHANGED_FILES=$(git diff --name-only $BASE_COMMIT_SHA $PR_COMMIT_SHA) | |
# Track which charts need bumping | |
NEEDS_BUMP=false | |
CHANGED_CHARTS="" | |
# Check each changed file | |
echo "$CHANGED_FILES" | while read -r file; do | |
echo "Processing file: $file" | |
if [[ $file == charts/*/templates/* ]] || [[ $file == charts/*/values.yaml ]] || [[ $file == charts/*/values.schema.json ]]; then | |
# Extract chart name from path | |
CHART_NAME=$(echo "$file" | cut -d'/' -f2) | |
CHART_YAML="charts/$CHART_NAME/Chart.yaml" | |
echo "Found chart: $CHART_NAME" | |
# Only check if we haven't already checked this chart | |
if [[ ! $CHANGED_CHARTS =~ $CHART_NAME ]]; then | |
echo "Processing Chart.yaml: $CHART_YAML" | |
CHANGED_CHARTS="$CHANGED_CHARTS $CHART_NAME" | |
if [ -f "$CHART_YAML" ]; then | |
# Get current version in PR | |
CURRENT_VERSION=$(yq eval '.version' "$CHART_YAML") | |
echo "Current version: $CURRENT_VERSION" | |
# Get version from base branch | |
BASE_VERSION=$(git show $BASE_COMMIT_SHA:"$CHART_YAML" | yq eval '.version' -) | |
echo "Base version: $BASE_VERSION" | |
if [ "$CURRENT_VERSION" == "$BASE_VERSION" ]; then | |
# Bump version | |
NEW_VERSION=$(bump_version "$CURRENT_VERSION") | |
echo "Bumping to new version: $NEW_VERSION" | |
yq eval ".version = \"$NEW_VERSION\"" -i "$CHART_YAML" | |
update_umbrella_charts | |
echo "Bumped $CHART_NAME version from $CURRENT_VERSION to $NEW_VERSION" | |
# Set output for next step | |
echo "versions_bumped=true" >> $GITHUB_OUTPUT | |
else | |
echo "Chart $CHART_NAME version has already been bumped from $BASE_VERSION to $CURRENT_VERSION" | |
fi | |
fi | |
fi | |
fi | |
done | |
- name: Commit and push changes | |
if: steps.version_check.outputs.versions_bumped == 'true' | |
run: | | |
# Make sure we're on the PR branch | |
git checkout ${{ github.head_ref }} | |
# Add and commit changes | |
git add charts/*/Chart.yaml | |
git commit -m "[AUTO GITHUB] Bump chart versions" | |
# Push to the PR branch | |
git push origin ${{ github.head_ref }} |