Skip to content

feat(deps): update public.ecr.aws/docker/library/alpine docker tag (3… #6

feat(deps): update public.ecr.aws/docker/library/alpine docker tag (3…

feat(deps): update public.ecr.aws/docker/library/alpine docker tag (3… #6

name: Update App Version
on:
push:
branches:
- main
paths:
- 'apps/buoy/Dockerfile'
# Add more specific Dockerfile paths here as needed
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Detect changed apps
id: changes
uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46.0.5
with:
files: ${{ join(github.event.paths, '\n') }}
- name: Set build matrix
id: set-matrix
run: |
if [ -n "${{ steps.changes.outputs.all_changed_files }}" ]; then
# Convert space-separated paths to newline-separated and extract app names
CHANGED_APPS=$(echo "${{ steps.changes.outputs.all_changed_files }}" | tr ' ' '\n' | grep -o "apps/[^/]*" | sort -u | cut -d/ -f2)
if [ -n "$CHANGED_APPS" ]; then
# Handle both single and multiple app names
if [[ "$CHANGED_APPS" == *$'\n'* ]]; then
# Multiple apps
APPS_JSON=$(echo "$CHANGED_APPS" | jq -R -s 'split("\n") | map(select(length > 0))')
else
# Single app
APPS_JSON=$(echo "[\"$CHANGED_APPS\"]")
fi
echo "matrix={\"app\":$APPS_JSON}" >> $GITHUB_OUTPUT
else
echo "matrix={\"app\":[]}" >> $GITHUB_OUTPUT
fi
else
echo "matrix={\"app\":[]}" >> $GITHUB_OUTPUT
fi
update-version:
needs: detect-changes
if: ${{ fromJson(needs.detect-changes.outputs.matrix).app[0] != null }}
runs-on: ubuntu-latest
strategy:
matrix: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: main
- name: Get current version
id: version
run: |
# Get version and store original format
VERSION_LINE=$(grep -E "^version:" apps/${{ matrix.app }}/metadata.yaml)
CURRENT_VERSION=$(echo "$VERSION_LINE" | sed -E 's/^version:\s*(.*)\s*$/\1/')
HAS_V_PREFIX=false
if [[ $CURRENT_VERSION == v* ]]; then
HAS_V_PREFIX=true
CURRENT_VERSION=${CURRENT_VERSION#v}
fi
# Increment version
MAJOR=$(echo $CURRENT_VERSION | cut -d. -f1)
MINOR=$(echo $CURRENT_VERSION | cut -d. -f2)
PATCH=$(echo $CURRENT_VERSION | cut -d. -f3)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
# Add v prefix if original had it
if [ "$HAS_V_PREFIX" = true ]; then
NEW_VERSION="v$NEW_VERSION"
fi
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"
- name: Update version in metadata
run: |
sed -i "s/^version:.*/version: ${{ steps.version.outputs.new_version }}/" apps/${{ matrix.app }}/metadata.yaml
- name: Create Pull Request
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "chore(${{ matrix.app }}): bump version to ${{ steps.version.outputs.new_version }}"
title: "chore(${{ matrix.app }}): bump version to ${{ steps.version.outputs.new_version }}"
body: |
Automated version bump for ${{ matrix.app }} to version ${{ steps.version.outputs.new_version }}
branch: update-${{ matrix.app }}-to-${{ steps.version.outputs.new_version }}
base: main
delete-branch: true