| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- ---
- name: Renovate - Sync Template Versions
- 'on':
- pull_request:
- branches:
- - main
- paths:
- - 'library/**'
- permissions:
- contents: write
- pull-requests: write
- jobs:
- sync-versions:
- name: Sync Template Versions
- # Only run on Renovate PRs
- if: startsWith(github.head_ref, 'renovate/')
- runs-on: ubuntu-latest
- steps:
- - name: Checkout PR branch
- uses: actions/checkout@v6
- with:
- ref: ${{ github.head_ref }}
- fetch-depth: 0 # Fetch all history to compare with main
- token: ${{ secrets.GITHUB_TOKEN }}
- - name: Detect changed template files
- id: changes
- run: |
- # Fetch main branch for comparison
- git fetch origin main:main
- # Get list of changed files in library/
- CHANGED_FILES=$(git diff --name-only main...HEAD | grep '^library/' | grep -E '\.(j2|yaml|yml)$' || true)
- if [ -n "$CHANGED_FILES" ]; then
- echo "Changed template files:"
- echo "$CHANGED_FILES"
- echo "files<<EOF" >> $GITHUB_OUTPUT
- echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
- echo "EOF" >> $GITHUB_OUTPUT
- echo "has_files=true" >> $GITHUB_OUTPUT
- else
- echo "No template files changed"
- echo "has_files=false" >> $GITHUB_OUTPUT
- fi
- - name: Run template version sync
- id: sync
- if: steps.changes.outputs.has_files == 'true'
- run: |
- echo "Running template version sync script..."
- chmod +x .github/scripts/sync-template-version.sh
- # Pass changed files to the script
- .github/scripts/sync-template-version.sh ${{ steps.changes.outputs.files }}
- - name: Check for template.yaml changes
- id: template_changes
- run: |
- if [[ -n $(git status --porcelain library/**/template.yaml) ]]; then
- echo "has_changes=true" >> $GITHUB_OUTPUT
- echo "Template version changes detected"
- else
- echo "has_changes=false" >> $GITHUB_OUTPUT
- echo "No template version changes needed"
- fi
- - name: Commit and push changes
- if: steps.template_changes.outputs.has_changes == 'true'
- run: |
- git config --local user.email "github-actions[bot]@users.noreply.github.com"
- git config --local user.name "github-actions[bot]"
- git add library/**/template.yaml
- git commit -m "chore: sync template versions with image updates"
- git push
|