renovate-sync-versions.yaml 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ---
  2. name: Renovate - Sync Template Versions
  3. 'on':
  4. pull_request:
  5. branches:
  6. - main
  7. paths:
  8. - 'library/**'
  9. permissions:
  10. contents: write
  11. pull-requests: write
  12. jobs:
  13. sync-versions:
  14. name: Sync Template Versions
  15. # Only run on Renovate PRs
  16. if: startsWith(github.head_ref, 'renovate/')
  17. runs-on: ubuntu-latest
  18. steps:
  19. - name: Checkout PR branch
  20. uses: actions/checkout@v6
  21. with:
  22. ref: ${{ github.head_ref }}
  23. fetch-depth: 0 # Fetch all history to compare with main
  24. token: ${{ secrets.GITHUB_TOKEN }}
  25. - name: Detect changed template files
  26. id: changes
  27. run: |
  28. # Fetch main branch for comparison
  29. git fetch origin main:main
  30. # Get list of changed files in library/
  31. CHANGED_FILES=$(git diff --name-only main...HEAD | grep '^library/' | grep -E '\.(j2|yaml|yml)$' || true)
  32. if [ -n "$CHANGED_FILES" ]; then
  33. echo "Changed template files:"
  34. echo "$CHANGED_FILES"
  35. echo "files<<EOF" >> $GITHUB_OUTPUT
  36. echo "$CHANGED_FILES" >> $GITHUB_OUTPUT
  37. echo "EOF" >> $GITHUB_OUTPUT
  38. echo "has_files=true" >> $GITHUB_OUTPUT
  39. else
  40. echo "No template files changed"
  41. echo "has_files=false" >> $GITHUB_OUTPUT
  42. fi
  43. - name: Run template version sync
  44. id: sync
  45. if: steps.changes.outputs.has_files == 'true'
  46. run: |
  47. echo "Running template version sync script..."
  48. chmod +x .github/scripts/sync-template-version.sh
  49. # Pass changed files to the script
  50. .github/scripts/sync-template-version.sh ${{ steps.changes.outputs.files }}
  51. - name: Check for template.yaml changes
  52. id: template_changes
  53. run: |
  54. if [[ -n $(git status --porcelain library/**/template.yaml) ]]; then
  55. echo "has_changes=true" >> $GITHUB_OUTPUT
  56. echo "Template version changes detected"
  57. else
  58. echo "has_changes=false" >> $GITHUB_OUTPUT
  59. echo "No template version changes needed"
  60. fi
  61. - name: Commit and push changes
  62. if: steps.template_changes.outputs.has_changes == 'true'
  63. run: |
  64. git config --local user.email "github-actions[bot]@users.noreply.github.com"
  65. git config --local user.name "github-actions[bot]"
  66. git add library/**/template.yaml
  67. git commit -m "chore: sync template versions with image updates"
  68. git push