From 25dc623dcf6677c48c6388e96462fb7dc58b7448 Mon Sep 17 00:00:00 2001 From: Rom1-B <8530352+Rom1-B@users.noreply.github.com> Date: Wed, 18 Nov 2026 13:08:58 +0100 Subject: [PATCH 1/2] Fix: keep target action references on sync --- .github/dependabot.yml | 5 ++++- .github/scripts/sync.sh | 20 +++++++++++++++++++ README.md | 1 + sync/files/.github/workflows/forward-port.yml | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 27b46d1..d47f69d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -2,6 +2,9 @@ version: 2 updates: # Ensure GitHub Actions are used in their latest version - package-ecosystem: "github-actions" - directory: "/" + directories: + - "/" + - "/sync/files" + - "/sync/files-public" schedule: interval: "monthly" diff --git a/.github/scripts/sync.sh b/.github/scripts/sync.sh index 01f3e69..33c597f 100755 --- a/.github/scripts/sync.sh +++ b/.github/scripts/sync.sh @@ -170,6 +170,14 @@ while read -r repo; do fi # Keep the plugin specific inputs and secrets of the ci job, written after its last common input ci_extra="$(sed '1,/db-image: "\${{ matrix.db-image }}"/d' "$repo_dir/$ci_file" 2>/dev/null || true)" + # Keep the action references of the repository, its Dependabot updates them on every branch without conflicting with this pull request + pins_dir="$work_dir/$name-pins" + for file in "${synced_files[@]}" "${public_files[@]}"; do + if [[ -s "$repo_dir/$file" ]]; then + mkdir -p "$pins_dir/$(dirname "$file")" + cp "$repo_dir/$file" "$pins_dir/$file" + fi + done cp -r "$files_dir/." "$repo_dir/" repo_files=("${synced_files[@]}") repo_deleted_paths=("${deleted_paths[@]}") @@ -181,6 +189,18 @@ while read -r repo; do fi for file in "${repo_files[@]}"; do sed -i -e "s/{PLUGIN}/${name}/g" -e "s/{GLPI_VERSION}/${glpi_version:-$default_glpi_version}/g" "$repo_dir/$file" + if [[ -f "$pins_dir/$file" ]]; then + # Replaces everything after "action@" with the repository value, version comment included + awk ' + match($0, /uses: "[^"@]+@/) { + action = substr($0, RSTART, RLENGTH) + if (FNR == NR) { pins[action] = substr($0, RSTART + RLENGTH); next } + if (action in pins) { $0 = substr($0, 1, RSTART + RLENGTH - 1) pins[action] } + } + FNR != NR { print } + ' "$pins_dir/$file" "$repo_dir/$file" > "$work_dir/pinned" + cat "$work_dir/pinned" > "$repo_dir/$file" + fi done if [[ -n "$ci_extra" ]]; then printf '%s\n' "$ci_extra" >> "$repo_dir/$ci_file" diff --git a/README.md b/README.md index 69aaaa0..49e7afd 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ The repository must also be granted to the sync GitHub App installation, otherwi - `{PLUGIN}` in a synced file is replaced by the target repository name. - `{GLPI_VERSION}` is replaced by the `glpi-version` currently set in the target continuous integration workflow (`12.0.x` when missing or not in the `X.Y.x` or `X.Y.Z` format). - Lines following `db-image` in the target continuous integration workflow (plugin specific inputs and secrets of the `ci` job) are kept. +- Action references (`uses: "owner/action@ref" # version`) already set in a target file are kept, so the target Dependabot updates them without conflicting with the sync pull request; references set here only apply to targets missing the action, and this repository's Dependabot keeps them up to date. - The npm entry of `dependabot.yml` is dropped when the target has no `package.json`. - Every `dependabot.yml` entry is duplicated with a `target-branch` for each branch of `sync/maintained-branches.txt` existing in the target: add a new `X.Y/bugfixes` branch there when it opens, remove it at its end of life. - Pull requests merged into a branch are forward-ported to the next one, the protected `X.Y/bugfixes` branches sorted by version then the default branch: the chain follows new branches without any change here. Pull requests labelled `no forward-port` or opened by bots (except forward-port pull requests) are skipped. diff --git a/sync/files/.github/workflows/forward-port.yml b/sync/files/.github/workflows/forward-port.yml index c2004fe..ef8aaed 100644 --- a/sync/files/.github/workflows/forward-port.yml +++ b/sync/files/.github/workflows/forward-port.yml @@ -85,7 +85,7 @@ jobs: - name: "Create forward-port pull request" if: steps.target.outputs.branch != '' - uses: "korthout/backport-action@8560fb503c275d433c56f05a2f64850093baa9f7" # v4.7.0 + uses: "korthout/backport-action@ad272ff24e4a8593bf18a951a154ae6af93b26b8" # v5.0.0 with: github_token: "${{ steps.app-token.outputs.token }}" target_branches: ${{ steps.target.outputs.branch }} From acf28e0f9559918d4503de6e66db3c3017e4cde2 Mon Sep 17 00:00:00 2001 From: Rom1-B <8530352+Rom1-B@users.noreply.github.com> Date: Mon, 23 Nov 2026 11:37:10 +0100 Subject: [PATCH 2/2] stan --- .github/dependabot.yml | 4 ++-- .github/scripts/sync.sh | 30 +++++++++++++++++++++++++++--- README.md | 2 +- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index d47f69d..9d9828b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -4,7 +4,7 @@ updates: - package-ecosystem: "github-actions" directories: - "/" - - "/sync/files" - - "/sync/files-public" + - "/sync/files/.github/workflows" + - "/sync/files-public/.github/workflows" schedule: interval: "monthly" diff --git a/.github/scripts/sync.sh b/.github/scripts/sync.sh index 33c597f..1044c82 100755 --- a/.github/scripts/sync.sh +++ b/.github/scripts/sync.sh @@ -190,12 +190,36 @@ while read -r repo; do for file in "${repo_files[@]}"; do sed -i -e "s/{PLUGIN}/${name}/g" -e "s/{GLPI_VERSION}/${glpi_version:-$default_glpi_version}/g" "$repo_dir/$file" if [[ -f "$pins_dir/$file" ]]; then - # Replaces everything after "action@" with the repository value, version comment included + # Replaces everything after "action@" with the repository value, version comment included, unless the template version is higher awk ' + # Version from the "# vX.Y.Z" comment, else from a "@vN" tag, empty when unknown + function version(ref, v) { + if (match(ref, /# v?[0-9]+(\.[0-9]+)*/)) { + v = substr(ref, RSTART + 2, RLENGTH - 2) + } else if (match(ref, /^v?[0-9]+(\.[0-9]+)*"/)) { + v = substr(ref, RSTART, RLENGTH - 1) + } + sub(/^v/, "", v) + return v + } + function at_least(a, b, x, y, n, i) { + n = split(a, x, ".") + if (split(b, y, ".") > n) { n = split(b, y, ".") } + for (i = 1; i <= n; i++) { + if (x[i] + 0 != y[i] + 0) { return x[i] + 0 > y[i] + 0 } + } + return 1 + } match($0, /uses: "[^"@]+@/) { + prefix = substr($0, 1, RSTART + RLENGTH - 1) action = substr($0, RSTART, RLENGTH) - if (FNR == NR) { pins[action] = substr($0, RSTART + RLENGTH); next } - if (action in pins) { $0 = substr($0, 1, RSTART + RLENGTH - 1) pins[action] } + ref = substr($0, RSTART + RLENGTH) + if (FNR == NR) { pins[action] = ref; next } + if (action in pins) { + pinned = version(pins[action]) + template = version(ref) + if (pinned != "" && template != "" && at_least(pinned, template)) { $0 = prefix pins[action] } + } } FNR != NR { print } ' "$pins_dir/$file" "$repo_dir/$file" > "$work_dir/pinned" diff --git a/README.md b/README.md index 49e7afd..f67907d 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ The repository must also be granted to the sync GitHub App installation, otherwi - `{PLUGIN}` in a synced file is replaced by the target repository name. - `{GLPI_VERSION}` is replaced by the `glpi-version` currently set in the target continuous integration workflow (`12.0.x` when missing or not in the `X.Y.x` or `X.Y.Z` format). - Lines following `db-image` in the target continuous integration workflow (plugin specific inputs and secrets of the `ci` job) are kept. -- Action references (`uses: "owner/action@ref" # version`) already set in a target file are kept, so the target Dependabot updates them without conflicting with the sync pull request; references set here only apply to targets missing the action, and this repository's Dependabot keeps them up to date. +- Action references (`uses: "owner/action@ref" # version`) already set in a target file are kept when their version is not lower than the one set here, so the target Dependabot updates them without conflicting with the sync pull request; otherwise, or when either version is unknown, the reference set here applies, and this repository's Dependabot keeps it up to date. - The npm entry of `dependabot.yml` is dropped when the target has no `package.json`. - Every `dependabot.yml` entry is duplicated with a `target-branch` for each branch of `sync/maintained-branches.txt` existing in the target: add a new `X.Y/bugfixes` branch there when it opens, remove it at its end of life. - Pull requests merged into a branch are forward-ported to the next one, the protected `X.Y/bugfixes` branches sorted by version then the default branch: the chain follows new branches without any change here. Pull requests labelled `no forward-port` or opened by bots (except forward-port pull requests) are skipped.