Skip to content

Commit ed6cda4

Browse files
chengfangclaude
andauthored
fix(hack): enhance hack/propagate.sh with git optimization, support custom argocd-operator branch (redhat-developer#1196)
* fix(hack): enhance hack/propagate.sh with git optimization, support custom argocd-operator branch, and inclusion in Makefile targets Signed-off-by: Cheng Fang <cfang@redhat.com> Co-authored-by: Claude <noreply@anthropic.com> * do not include propagate-manifests target as a dependent of bundle target to avoid affecting existing usage Signed-off-by: Cheng Fang <cfang@redhat.com> --------- Signed-off-by: Cheng Fang <cfang@redhat.com> Co-authored-by: Claude <noreply@anthropic.com>
1 parent 062ab2d commit ed6cda4

2 files changed

Lines changed: 46 additions & 4 deletions

File tree

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,16 @@ bundle-build: ## Build the bundle image.
281281
bundle-push: ## Push the bundle image.
282282
$(MAKE) docker-push IMG=$(BUNDLE_IMG)
283283

284+
ARGOCD_OPERATOR_BRANCH ?= master
285+
286+
# To run propagate-manifests target with the default argocd-operator master branch:
287+
# make propagate-manifests
288+
# To run propagate-manifests target with a custom argocd-operator branch or tag:
289+
# ARGOCD_OPERATOR_BRANCH=release-0.19 make propagate-manifests
290+
.PHONY: propagate-manifests
291+
propagate-manifests: ## compare and propagate manifests from argocd-operator repo
292+
./hack/propagate.sh --from-branch $(ARGOCD_OPERATOR_BRANCH)
293+
284294
.PHONY: opm
285295
OPM = ./bin/opm
286296
opm: ## Download opm locally if necessary.

hack/propagate.sh

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,34 @@
22

33
set -e
44

5+
FROM_BRANCH="master"
6+
SKIP_MAKE=false
7+
8+
usage() {
9+
echo "Usage: $0 [--from-branch <branch>] [--skip-make]"
10+
echo ""
11+
echo "Options:"
12+
echo " --from-branch <branch> argocd-operator repo branch or tag to source manifests from (default: master)"
13+
echo " --skip-make skip running 'make bundle' after copying changed files (default: false)"
14+
exit 1
15+
}
16+
17+
while [[ $# -gt 0 ]]; do
18+
case "$1" in
19+
--from-branch)
20+
FROM_BRANCH="$2"
21+
shift 2
22+
;;
23+
--skip-make)
24+
SKIP_MAKE=true
25+
shift
26+
;;
27+
*)
28+
usage
29+
;;
30+
esac
31+
done
32+
533
trap cleanup EXIT
634

735
function cleanup {
@@ -11,7 +39,7 @@ function cleanup {
1139

1240
mkdir -p /tmp/argocd-operator-hack
1341

14-
git clone https://github.com/argoproj-labs/argocd-operator.git /tmp/argocd-operator-hack/
42+
git clone --depth 1 --branch "$FROM_BRANCH" --single-branch --no-tags https://github.com/argoproj-labs/argocd-operator.git /tmp/argocd-operator-hack/
1543

1644
changedFiles=$(diff -qr /tmp/argocd-operator-hack/config/crd/bases/ ../config/crd/bases/ | grep -v argoproj.io_argocdexports.yaml | grep differ | awk -F ' ' '{print $2}')
1745

@@ -22,7 +50,11 @@ if [ -z "$changedFiles" ]
2250
then
2351
echo "No difference found"
2452
else
25-
cp ${changedFiles} ../config/crd/bases/
26-
cd ..
27-
make bundle
53+
cp ${changedFiles} ../config/crd/bases/
54+
if [ "$SKIP_MAKE" = false ]; then
55+
cd ..
56+
make bundle
57+
else
58+
echo "Skipping 'make bundle' (--skip-make specified)"
59+
fi
2860
fi

0 commit comments

Comments
 (0)