name: Update app version in Renovate Branches on: push: branches: - 'renovate/*' - 'selfhosted-renovate/*' workflow_dispatch: inputs: manual-trigger: description: 'Manually trigger Renovate' default: '' jobs: update-app-version: if: > github.event_name == 'workflow_dispatch' || startsWith(github.ref_name, 'renovate/') || startsWith(github.ref_name, 'selfhosted-renovate/') runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7 with: fetch-depth: 0 - name: Configure repo run: | git config --local user.email "githubaction@githubaction.com" git config --local user.name "github-action update-app-version" - name: Get list of updated files by the last commit in this branch separated by space id: updated-files run: | base_ref="${{ github.event.before }}" if [[ -z "$base_ref" || "$base_ref" =~ ^0+$ ]]; then base_ref="HEAD^" fi echo "base_ref=$base_ref" >> "$GITHUB_OUTPUT" echo "files=$(git diff --name-only "$base_ref" "${{ github.sha }}" | tr '\n' ' ')" >> "$GITHUB_OUTPUT" - name: Run renovate-app-version.sh on updated files run: | IFS=' ' read -ra files <<< "${{ steps.updated-files.outputs.files }}" for file in "${files[@]}"; do if [[ $file == *"docker-compose.yml"* ]]; then app_name=$(echo "$file" | cut -d'/' -f 2) old_version=$(echo "$file" | cut -d'/' -f 3) chmod +x .github/workflows/renovate-app-version.sh .github/workflows/renovate-app-version.sh \ "$app_name" \ "$old_version" \ "$file" \ "${{ steps.updated-files.outputs.base_ref }}" fi done - name: Commit & Push Changes run: | IFS=' ' read -ra files <<< "${{ steps.updated-files.outputs.files }}" declare -A apps=() for file in "${files[@]}"; do if [[ $file == *"docker-compose.yml"* ]]; then app_name=$(echo "$file" | cut -d'/' -f 2) apps["$app_name"]=1 fi done for app_name in "${!apps[@]}"; do git add "apps/$app_name" if git diff --cached --quiet; then continue fi git commit -m "Update app version [skip ci]" --no-verify git push done