diff --git a/stakater-pr-cleaner/rendered/stakater-pr-cleaner-0.0.6.yaml b/stakater-pr-cleaner/rendered/stakater-pr-cleaner-0.0.6.yaml new file mode 100644 index 0000000..8435868 --- /dev/null +++ b/stakater-pr-cleaner/rendered/stakater-pr-cleaner-0.0.6.yaml @@ -0,0 +1,94 @@ +--- +# Source: stakater-pr-cleaner/templates/clustertask.yaml +apiVersion: tekton.dev/v1beta1 +kind: Task +metadata: + name: stakater-pr-cleaner-0.0.6 +spec: + params: + - name: PR_NUMBER + description: In case of PR, PR number that is to be used in image tag. If this field is empty it means that it's a commit on main branch + default: "NA" + - name: REPO_PATH + description: Path of repository with group name + default: "NA" + - name: GIT_ORGANIZATION + description: Git organization URL + default: "" + - name: GIT_CD_REPO + description: The Directory to update CD manifests + default: "" + - name: TEAM + description: The git revision + default: "NA" + - name: NAMESPACE + description: Build namespace + stepTemplate: + resources: + requests: + cpu: 250m + memory: 1Gi + steps: + - name: update-cd-repo-on-merge + image: stakater/pipeline-toolbox:v0.0.31 + command: ["/bin/bash"] + env: + - name: GIT_PASSWORD + valueFrom: + secretKeyRef: + name: github-stakater-tekton-bot + key: password + - name: GIT_USERNAME + valueFrom: + secretKeyRef: + name: github-stakater-tekton-bot + key: username + - name: GIT_EMAIL + valueFrom: + secretKeyRef: + name: github-stakater-tekton-bot + key: email + args: + - -c + - | + git clone https://$(params.GIT_ORGANIZATION)/$(params.GIT_CD_REPO) + + cd $(inputs.params.GIT_CD_REPO) + + if [ $(params.TEAM) == "NA" ]; then + TEAM=$(echo $(params.NAMESPACE) | cut -d'-' -f 1) + else + TEAM=$(params.TEAM) + fi + + echo "TEAM is ${TEAM}" + + REPO=$(echo $(inputs.params.REPO_PATH) | rev | cut -d'/' -f 1 | rev ) + + echo "Repo is ${REPO}" + + cd *$TEAM + + cd apps + + cd *$REPO + + git config --global user.name $GIT_USERNAME + + git config --global user.email $GIT_EMAIL + + rm *preview/pr-$(inputs.params.PR_NUMBER).yaml + + git add . + + git commit -m "remove manifest for ${REPO} pr - + $(inputs.params.PR_NUMBER)" + + git push + while [ $? -ne 0 ]; do + echo "Error on Push" + echo "Pulling via Rebase" + git pull --rebase + echo "Pushing" + git push + done