mirror of
https://github.com/bitnami/containers.git
synced 2026-02-10 03:15:53 +08:00
Add support for syncing single containers
Signed-off-by: Miguel A. Cabrera Minagorri <mcabrera@vmware.com>
This commit is contained in:
committed by
Bitnami Containers
parent
9d5925f598
commit
2ceddcb655
5
.github/workflows/sync.yaml
vendored
5
.github/workflows/sync.yaml
vendored
@@ -9,6 +9,9 @@ on:
|
|||||||
shift:
|
shift:
|
||||||
description: 'Commits to shift if you edited the containers folder'
|
description: 'Commits to shift if you edited the containers folder'
|
||||||
default: '0'
|
default: '0'
|
||||||
|
container:
|
||||||
|
description: 'Sync only the container specified'
|
||||||
|
default: ''
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Trigger Site Rebuild
|
name: Trigger Site Rebuild
|
||||||
@@ -20,4 +23,4 @@ jobs:
|
|||||||
token: ${{ secrets.BITNAMI_BOT_SECRET }}
|
token: ${{ secrets.BITNAMI_BOT_SECRET }}
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Fetch
|
- name: Fetch
|
||||||
run: ./scripts/fetch-commits.sh ${{ github.event.inputs.shift }}
|
run: ./scripts/fetch-commits.sh ${{ github.event.inputs.shift }} ${{ github.event.inputs.container }}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
# Bitnami Containers
|
# Bitnami Containers
|
||||||
|
|
||||||
> NOTE: We use the latest commit to know the missing ones to sync. Do not edit this repository manually or the sync will be broken.
|
> NOTE: We use the latest commit to know the missing ones to sync. Do not edit this repository manually or the sync will be broken.
|
||||||
> If you edit this repo please take care of scifying how many commits you added into the `COMMIT_SHIFT` env var when calling the `fetch-commits.sh` script
|
> If you edit this repo please run the sync workflow manually providing:
|
||||||
|
> - how many commits you added into the `shift` parameter.
|
||||||
|
> - the container you affected into the `container` parameter.
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ set -o xtrace # Uncomment this line for debugging purpose
|
|||||||
TARGET_DIR="."
|
TARGET_DIR="."
|
||||||
|
|
||||||
COMMIT_SHIFT="${1:-0}" # Used when you push commits manually
|
COMMIT_SHIFT="${1:-0}" # Used when you push commits manually
|
||||||
|
CONTAINER="${2:-}" # USed when we want to sync a single container
|
||||||
|
|
||||||
function queryRepos() {
|
function queryRepos() {
|
||||||
local page=0
|
local page=0
|
||||||
@@ -45,7 +46,7 @@ function gitConfigure() {
|
|||||||
function pushChanges() {
|
function pushChanges() {
|
||||||
git config user.name "Bitnami Containers"
|
git config user.name "Bitnami Containers"
|
||||||
git config user.email "containers@bitnami.com"
|
git config user.email "containers@bitnami.com"
|
||||||
git push
|
git push origin main
|
||||||
}
|
}
|
||||||
|
|
||||||
function findCommitsToSync() {
|
function findCommitsToSync() {
|
||||||
@@ -70,7 +71,7 @@ function findCommitsToSync() {
|
|||||||
max=$((max - 1))
|
max=$((max - 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
[[ "$max" -eq "0" ]] && echo "Last commit not found into the original repo history" && exit 1
|
[[ "$max" -eq "0" ]] && echo "Last commit not found into the original repo history" && return 1
|
||||||
printf "$commits_to_sync"
|
printf "$commits_to_sync"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,33 +84,47 @@ syncCommit() {
|
|||||||
rm -f "$patch_file"
|
rm -f "$patch_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncRepos() {
|
syncContainerCommits() {
|
||||||
local -r repos="$(getContainerRepos)"
|
local -r name="${1:?Missing container name}"
|
||||||
|
local -r repo_url="https://github.com/bitnami/bitnami-docker-${name}"
|
||||||
gitConfigure # Configure Git client
|
(
|
||||||
|
cd "$TARGET_DIR"
|
||||||
mkdir -p "$TARGET_DIR"
|
# Fetch the old repo master
|
||||||
|
git remote add --fetch "$name" "$repo_url"
|
||||||
# Build array of app names since we need to exclude them when moving files
|
read -r -a commits_to_sync <<< "$(findCommitsToSync "$name")"
|
||||||
local apps=("mock")
|
if [[ "${#commits_to_sync[@]}" -eq "0" ]]; then
|
||||||
local -r urls=($(echo "$repos" | jq -r '.[].html_url' | sort | uniq))
|
echo "Nothing to sync for ${name}"
|
||||||
for repo_url in "${urls[@]}"; do
|
else
|
||||||
name="${repo_url:42}" # 42 is the length of https://github.com/bitnami/bitnami-docker-
|
|
||||||
apps=("${apps[@]}" "$name")
|
|
||||||
done
|
|
||||||
echo "$repos" | jq -r '.[].html_url' | sort | uniq | while read -r repo_url; do
|
|
||||||
name="${repo_url:42}" # 42 is the length of https://github.com/bitnami/bitnami-docker-
|
|
||||||
(
|
|
||||||
cd "$TARGET_DIR"
|
|
||||||
# Fetch the old repo master
|
|
||||||
git remote add --fetch "$name" "$repo_url"
|
|
||||||
read -r -a commits_to_sync <<< "$(findCommitsToSync "$name")"
|
|
||||||
for commit in "${commits_to_sync[@]}"; do
|
for commit in "${commits_to_sync[@]}"; do
|
||||||
syncCommit "$commit" "$name"
|
syncCommit "$commit" "$name"
|
||||||
done
|
done
|
||||||
git remote remove "$name"
|
fi
|
||||||
)
|
git remote remove "$name"
|
||||||
done
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncRepos() {
|
||||||
|
|
||||||
|
gitConfigure # Configure Git client
|
||||||
|
mkdir -p "$TARGET_DIR"
|
||||||
|
|
||||||
|
if [[ -z "$CONTAINER" ]]; then
|
||||||
|
local -r repos="$(getContainerRepos)"
|
||||||
|
|
||||||
|
# Build array of app names since we need to exclude them when moving files
|
||||||
|
local apps=("mock")
|
||||||
|
local -r urls=($(echo "$repos" | jq -r '.[].html_url' | sort | uniq))
|
||||||
|
for repo_url in "${urls[@]}"; do
|
||||||
|
name="${repo_url:42}" # 42 is the length of https://github.com/bitnami/bitnami-docker-
|
||||||
|
apps=("${apps[@]}" "$name")
|
||||||
|
done
|
||||||
|
echo "$repos" | jq -r '.[].html_url' | sort | uniq | while read -r repo_url; do
|
||||||
|
name="${repo_url:42}" # 42 is the length of https://github.com/bitnami/bitnami-docker-
|
||||||
|
syncContainerCommits "$name"
|
||||||
|
done
|
||||||
|
else
|
||||||
|
syncContainerCommits "$CONTAINER"
|
||||||
|
fi
|
||||||
|
|
||||||
pushChanges
|
pushChanges
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user