From 8d7b9544c36e924e82a6e531829cf789b13ac0c6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Thu, 13 Oct 2022 16:02:50 +0000 Subject: [PATCH 01/14] chore(deps): add renovate.json --- renovate.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 renovate.json diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..39a2b6e9 --- /dev/null +++ b/renovate.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ] +} From 1e2da3655ead68cb5bb2d791e44bb4b7892aa3a0 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 12:05:56 -0400 Subject: [PATCH 02/14] Delete ci.yml --- .github/workflows/ci.yml | 44 ---------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index dbd385c1..00000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,44 +0,0 @@ -name: Tipi CI -on: - push: - -jobs: - ci: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - - - uses: pnpm/action-setup@v2.0.1 - name: Install pnpm - id: pnpm-install - with: - version: 7 - run_install: false - - - name: Get pnpm store directory - id: pnpm-cache - run: | - echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" - - - uses: actions/cache@v3 - name: Setup pnpm cache - with: - path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} - key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} - restore-keys: | - ${{ runner.os }}-pnpm-store- - - - name: Install dependencies - run: pnpm install - - - name: Run global tests - run: pnpm test - - - name: Run linter - run: pnpm run lint \ No newline at end of file From 2d7519e6eb3e8e59acd25a26f9daa723697ff9f7 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 12:10:02 -0400 Subject: [PATCH 03/14] Limit managers --- renovate.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/renovate.json b/renovate.json index 39a2b6e9..032a3e37 100644 --- a/renovate.json +++ b/renovate.json @@ -2,5 +2,8 @@ "$schema": "https://docs.renovatebot.com/renovate-schema.json", "extends": [ "config:base" - ] + ], + { + "enabledManagers": ["docker-compose", "dockerfile"] + } } From cdd3d227e829ca077df34c41f383ba319c3d23b0 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 12:11:54 -0400 Subject: [PATCH 04/14] Update renovate.json --- renovate.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/renovate.json b/renovate.json index 032a3e37..137b3a4a 100644 --- a/renovate.json +++ b/renovate.json @@ -3,7 +3,5 @@ "extends": [ "config:base" ], - { - "enabledManagers": ["docker-compose", "dockerfile"] - } + "enabledManagers": ["docker-compose", "dockerfile"] } From f713cf835950362ba37414603f32f53d52a6c796 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 12:22:15 -0400 Subject: [PATCH 05/14] Add dash --- renovate.json | 1 + 1 file changed, 1 insertion(+) diff --git a/renovate.json b/renovate.json index 137b3a4a..e57b6c68 100644 --- a/renovate.json +++ b/renovate.json @@ -3,5 +3,6 @@ "extends": [ "config:base" ], + "dependencyDashboard": true, "enabledManagers": ["docker-compose", "dockerfile"] } From c5532729dd2f86848c0326c87cc8cfe49a9df8dd Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 12:42:41 -0400 Subject: [PATCH 06/14] Renovate action --- .github/workflows/renovate.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/renovate.yml diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml new file mode 100644 index 00000000..fc0404de --- /dev/null +++ b/.github/workflows/renovate.yml @@ -0,0 +1,30 @@ +name: Renovate + +on: + workflow_dispatch: + inputs: + log-level: + type: choice + description: Select log level for Renovate + options: + - trace + - debug + - info + - warn + - error + default: into + required: false + schedule: + # The "*" (#42, asterisk) character has special semantics in YAML, so this + # string has to be quoted. + - cron: '0/15 * * * *' +jobs: + renovate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2.0.0 + - name: Self-hosted Renovate + uses: renovatebot/github-action@v32.118.0 + with: + token: ${{ secrets.RENOVATE_TOKEN }} From 3b4d8515c7eee4f2dfda530bdbbad19a0352f4b0 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 13:05:19 -0400 Subject: [PATCH 07/14] 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 08/14] 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 From 44eea5446026c94678afd6ad1efb66c91d7e128a Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 14:14:58 -0400 Subject: [PATCH 09/14] Chmod --- .github/workflows/renovate-app-version.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 .github/workflows/renovate-app-version.sh diff --git a/.github/workflows/renovate-app-version.sh b/.github/workflows/renovate-app-version.sh old mode 100644 new mode 100755 From 711e66542ccb7916726ea9f7faedb809df699d7c Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 14:20:40 -0400 Subject: [PATCH 10/14] Revert "Delete ci.yml" This reverts commit 1e2da3655ead68cb5bb2d791e44bb4b7892aa3a0. --- .github/workflows/ci.yml | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..dbd385c1 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: Tipi CI +on: + push: + +jobs: + ci: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + + - uses: pnpm/action-setup@v2.0.1 + name: Install pnpm + id: pnpm-install + with: + version: 7 + run_install: false + + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Run global tests + run: pnpm test + + - name: Run linter + run: pnpm run lint \ No newline at end of file From 2f55be175e429a92843c4fefab97ab7bf5e350ff Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 14:41:01 -0400 Subject: [PATCH 11/14] Ignore github actions --- renovate.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/renovate.json b/renovate.json index e57b6c68..ece6e254 100644 --- a/renovate.json +++ b/renovate.json @@ -3,6 +3,10 @@ "extends": [ "config:base" ], + // Ignore commits produced by github actions workflows + "gitIgnoredAuthors": [ + "githubaction@githubaction.com" + ], "dependencyDashboard": true, "enabledManagers": ["docker-compose", "dockerfile"] } From c59efd10a7cb07ed46a8842969aca31e163cada4 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 14:41:33 -0400 Subject: [PATCH 12/14] Remove comment, not json5 --- renovate.json | 1 - 1 file changed, 1 deletion(-) diff --git a/renovate.json b/renovate.json index ece6e254..77b47280 100644 --- a/renovate.json +++ b/renovate.json @@ -3,7 +3,6 @@ "extends": [ "config:base" ], - // Ignore commits produced by github actions workflows "gitIgnoredAuthors": [ "githubaction@githubaction.com" ], From 3dd7d7fe7d1ad2a71fb746c6a4a3044a9620f446 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 16:49:14 -0400 Subject: [PATCH 13/14] update tipi_version --- .github/workflows/renovate-app-version.sh | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/.github/workflows/renovate-app-version.sh b/.github/workflows/renovate-app-version.sh index 7f7d7d15..b1c9486c 100755 --- a/.github/workflows/renovate-app-version.sh +++ b/.github/workflows/renovate-app-version.sh @@ -21,8 +21,17 @@ do # 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 + current_config_version=$(jq -r '.version' $config_file) + + # Update the version in config.json, but only if there's a change + if [[ "$current_config_version" != "$trimmed_version" ]]; then + contents="$(jq --arg trimmed_version "$trimmed_version" '.version=$trimmed_version' $config_file)" + echo "${contents}" > $config_file + + tipi_version=$(jq -r '.tipi_version' $config_file) + tipi_version=$((tipi_version + 1)) + contents="$(jq --argjson tipi_version $tipi_version '.tipi_version=$tipi_version' $config_file)" + echo "${contents}" > $config_file + fi fi done \ No newline at end of file From b920b326d6f1952cc05e4800f3c9210ba7ccced4 Mon Sep 17 00:00:00 2001 From: Brahim Hadriche Date: Thu, 13 Oct 2022 17:03:28 -0400 Subject: [PATCH 14/14] Update renovate action to update only current app --- .github/workflows/renovate-app-version.sh | 6 ++++-- .github/workflows/renovate-app-version.yml | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/renovate-app-version.sh b/.github/workflows/renovate-app-version.sh index b1c9486c..fa6764f5 100755 --- a/.github/workflows/renovate-app-version.sh +++ b/.github/workflows/renovate-app-version.sh @@ -1,8 +1,10 @@ #!/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) +app_name=$1 + +# find all docker-compose files under apps/$app_name (there should be only one) +docker_compose_files=$(find apps/$app_name -name docker-compose.yml) for docker_compose_file in $docker_compose_files do diff --git a/.github/workflows/renovate-app-version.yml b/.github/workflows/renovate-app-version.yml index 06b0bc33..324a5962 100644 --- a/.github/workflows/renovate-app-version.yml +++ b/.github/workflows/renovate-app-version.yml @@ -15,10 +15,23 @@ jobs: run: | git config --local user.email "githubaction@githubaction.com" git config --local user.name "github-action update-app-version" - - - name: Update app version + + - name: Get list of updated files by the last commit seperated by space + id: updated-files run: | - ./.github/workflows/renovate-app-version.sh + echo ${{github.sha}} + echo "::set-output name=files::$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | tr '\n' ' ')" + + - 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) + ./.github/workflows/renovate-app-version.sh $app_name + fi + done - name: Commit & Push Changes run: |