Merge pull request #67 from iBicha/master

Add Renovate integration
This commit is contained in:
Nicolas Meienberger 2022-10-13 21:15:14 +00:00 committed by GitHub
commit 1c9caf7391
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 118 additions and 0 deletions

39
.github/workflows/renovate-app-version.sh vendored Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
# This script copies the version from docker-compose.yml to config.json.
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
# 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}
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

View File

@ -0,0 +1,38 @@
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: Get list of updated files by the last commit seperated by space
id: updated-files
run: |
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: |
git add "apps/*/config.json" && git commit -m "Update app version" && git push || true

30
.github/workflows/renovate.yml vendored Normal file
View File

@ -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 }}

11
renovate.json Normal file
View File

@ -0,0 +1,11 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:base"
],
"gitIgnoredAuthors": [
"githubaction@githubaction.com"
],
"dependencyDashboard": true,
"enabledManagers": ["docker-compose", "dockerfile"]
}