Skip to content

Commit 0e93d78

Browse files
authored
mintmaker: add staging to production promotion pipeline (#5171)
Add PipelineRun to automatically promote changes from staging to production. When mintmaker staging kustomization.yaml is updated, the pipeline: - Updates production kustomization.yaml with corresponding SHAs from staging - Creates a pull request if any SHAs have changed This automates the staging to production promotion workflow for mintmaker.
1 parent d2060ca commit 0e93d78

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
apiVersion: tekton.dev/v1beta1
2+
kind: PipelineRun
3+
metadata:
4+
name: mintmaker-prod-overlay-update
5+
namespace: tekton-ci
6+
annotations:
7+
pipelinesascode.tekton.dev/on-cel-expression: |
8+
event == "push" && target_branch == "main" && "components/mintmaker/staging/base/kustomization.yaml".pathChanged()
9+
pipelinesascode.tekton.dev/max-keep-runs: "5"
10+
pipelinesascode.tekton.dev/task: "[.tekton/tasks/promote-component.yaml]"
11+
spec:
12+
pipelineSpec:
13+
tasks:
14+
- name: promote-component-from-stage-to-prod
15+
params:
16+
- name: BRANCH_NAME
17+
value: stage-to-prod-mintmaker
18+
- name: COMPONENT_NAME
19+
value: mintmaker
20+
- name: SCRIPT
21+
value: |
22+
# Extract SHAs from staging
23+
DEFAULT_CONFIG_SHA=$(awk -F= '/default\?ref=/{print $2}' staging/base/kustomization.yaml)
24+
RENOVATE_CONFIG_SHA=$(awk -F= '/renovate\?ref=/{print $2}' staging/base/kustomization.yaml)
25+
CONTROLLER_IMAGE_SHA=$(awk '/newName: quay\.io\/konflux-ci\/mintmaker$/{p=NR+1} NR<=p{if($1=="newTag:") print $2}' staging/base/kustomization.yaml)
26+
RENOVATE_IMAGE_SHA=$(awk '/newName: quay\.io\/konflux-ci\/mintmaker-renovate-image$/{p=NR+1} NR<=p{if($1=="newTag:") print $2}' staging/base/kustomization.yaml)
27+
28+
# Update SHAs in production
29+
if [ -n "$DEFAULT_CONFIG_SHA" ]; then
30+
echo "Updating prod default config SHA to $DEFAULT_CONFIG_SHA"
31+
sed -i "/default?ref/s/ref=.*$/ref=$DEFAULT_CONFIG_SHA/" production/base/kustomization.yaml
32+
fi
33+
34+
if [ -n "$RENOVATE_CONFIG_SHA" ]; then
35+
echo "Updating prod renovate config SHA to $RENOVATE_CONFIG_SHA"
36+
sed -i "/renovate?ref/s/ref=.*$/ref=$RENOVATE_CONFIG_SHA/" production/base/kustomization.yaml
37+
fi
38+
39+
if [ -n "$CONTROLLER_IMAGE_SHA" ]; then
40+
echo "Updating prod controller image SHA to $CONTROLLER_IMAGE_SHA"
41+
sed -i "/newName: quay\.io\/konflux-ci\/mintmaker$/,/newTag:/s/newTag:.*/newTag: $CONTROLLER_IMAGE_SHA/" production/base/kustomization.yaml
42+
fi
43+
44+
if [ -n "$RENOVATE_IMAGE_SHA" ]; then
45+
echo "Updating prod renovate image SHA to $RENOVATE_IMAGE_SHA"
46+
sed -i "/newName: quay\.io\/konflux-ci\/mintmaker-renovate-image$/,/newTag:/s/newTag:.*/newTag: $RENOVATE_IMAGE_SHA/" production/base/kustomization.yaml
47+
fi
48+
49+
echo "Updated production kustomization.yaml with staging SHAs"
50+
taskRef:
51+
name: promote-component

0 commit comments

Comments
 (0)