Merge pull request #5 from iBicha/feat/renovate-app-version
Update app version in Renovate Branches
This commit is contained in:
		
						commit
						c2a101dcda
					
				
							
								
								
									
										28
									
								
								.github/workflows/renovate-app-version.sh
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								.github/workflows/renovate-app-version.sh
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,28 @@
 | 
				
			||||||
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					# This script copies the version from docker-compose.yml to config.json.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# find all docker-compose files
 | 
				
			||||||
 | 
					docker_compose_files=$(find apps -name docker-compose.yml)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					for docker_compose_file in $docker_compose_files
 | 
				
			||||||
 | 
					do
 | 
				
			||||||
 | 
						# Assuming that the app version will be from the first docker image
 | 
				
			||||||
 | 
						first_service=$(yq '.services | keys | .[0]' $docker_compose_file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						image=$(yq .services.$first_service.image $docker_compose_file)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						# Only apply changes if the format is <image>:<version>
 | 
				
			||||||
 | 
						if [[ "$image" == *":"* ]]; then
 | 
				
			||||||
 | 
						  version=$(cut -d ":" -f2- <<< "$image")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  # Trim the "v" prefix
 | 
				
			||||||
 | 
						  trimmed_version=${version/#"v"}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  # Find config file
 | 
				
			||||||
 | 
						  config_file=${docker_compose_file/docker-compose.yml/config.json}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						  # Update the version in config.json
 | 
				
			||||||
 | 
						  contents="$(jq --arg trimmed_version "$trimmed_version" '.version=$trimmed_version' $config_file)" &&
 | 
				
			||||||
 | 
						  echo "${contents}" > $config_file
 | 
				
			||||||
 | 
						fi
 | 
				
			||||||
 | 
					done
 | 
				
			||||||
							
								
								
									
										25
									
								
								.github/workflows/renovate-app-version.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								.github/workflows/renovate-app-version.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,25 @@
 | 
				
			||||||
 | 
					name: Update app version in Renovate Branches
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					on:
 | 
				
			||||||
 | 
					  push:
 | 
				
			||||||
 | 
					    branches: [ 'renovate/*' ]
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  update-app-version:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					      - name: Checkout
 | 
				
			||||||
 | 
					        uses: actions/checkout@v3
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					      - name: Configure repo
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          git config --local user.email "githubaction@githubaction.com"
 | 
				
			||||||
 | 
					          git config --local user.name "github-action update-app-version"
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      - name: Update app version
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          ./.github/workflows/renovate-app-version.sh
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      - name: Commit & Push Changes
 | 
				
			||||||
 | 
					        run: |
 | 
				
			||||||
 | 
					          git add "apps/*/config.json" && git commit -m "Update app version" && git push || true
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user