Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
20 changes: 20 additions & 0 deletions .github/scripts/sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}")
Expand All @@ -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"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion sync/files/.github/workflows/forward-port.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Loading