From 3b4d8515c7eee4f2dfda530bdbbad19a0352f4b0 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 13:05:19 -0400 Subject: [PATCH 1/2] Create renovate-app-version.yml --- .github/workflows/renovate-app-version.yml | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/renovate-app-version.yml diff --git a/.github/workflows/renovate-app-version.yml b/.github/workflows/renovate-app-version.yml new file mode 100644 index 00000000..06b0bc33 --- /dev/null +++ b/.github/workflows/renovate-app-version.yml @@ -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 From a75ffeb522a087ee918d5f48b4575c44209c09dd Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 14:09:28 -0400 Subject: [PATCH 2/2] Add files via upload --- .github/workflows/renovate-app-version.sh | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/renovate-app-version.sh diff --git a/.github/workflows/renovate-app-version.sh b/.github/workflows/renovate-app-version.sh new file mode 100644 index 00000000..7f7d7d15 --- /dev/null +++ b/.github/workflows/renovate-app-version.sh @@ -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 : + 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 \ No newline at end of file