Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
faeb657572
Switch branches/tags
Go to file
 
 
Cannot retrieve contributors at this time
159 lines (158 sloc) 5.72 KB
# A Tekton Task to update the model, and create a PR
#
# Modifications are based on running kpt set
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: clone-modify-pr
annotations:
# This gets passed down to the individual pods
sidecar.istio.io/inject: "false"
spec:
params:
- name: automl-model
description: "The name of the automl-model to use in the form projects/${PROJECT}/locations/${LOCATION}/models/${ID}"
- name: branchName
type: string
description: The name to give to the branch to create
- name: fork
type: string
default: fork
description: The url of the remote repo for the fork
- name: forkName
type: string
default: fork
description: (Optional) The name to give to the remote repo for the fork
- name: upstreamName
type: string
default: origin
description: (Optional) The name of the remote repository corresponding to the
upstream URL
#**********************************************************************
# Create PR parameters
- name: gitHubAppId
type: string
default: "71466"
description: AppID for the GitHub app used to create PRs
- name: forkOwner
type: string
default: kubeflow
description: (Optional) The GitHub org/user that is the owner of the fork repository
- name: gitHubAppPrivateKeySecretName
type: string
default: label-bot-cd-github-private-key
description: Name of the secret containing the github app private key
- name: gitHubAppPrivateKeyFileName
type: string
default: github-private-key
description: Name of the file in gitHubAppPrivateKeySecretName containing the
private key
#**********************************************************************
# Image parameters
- name: prctl-image
type: string
default: "gcr.io/kubeflow-images-public/prctl:a1a488e@sha256:53b4e6ff048adf8a4f9afc623e533456c7ace944f9bf03c527f07e597c86ae8c" # {"type":"string","x-kustomize":{"setBy":"kpt","partialSetters":[{"name":"prctl-image","value":"gcr.io/kubeflow-images-public/prctl:a1a488e@sha256:53b4e6ff048adf8a4f9afc623e533456c7ace944f9bf03c527f07e597c86ae8c"}]}}
description: The image containing prctl
- name: kpt-image
type: string
# Should be 0.30.1 kpt image
default: gcr.io/kpt-dev/kpt@sha256:8a621c8e4b4d1cf5ec71f43aa099c120a78291896664a2cdb2c965a5726479ad
description: kpt image to use
resources:
inputs:
- name: repo
type: git
description: The GitHub repo containing the code to modify
steps:
# Create a branch
- name: branch
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
# Need to use script as workaround not to error out in tests.
# If any of the steps returns non-zero codes, subsequent steps will not be run.
args:
- branch
- --json-logs
- --branchName=$(inputs.params.branchName)
- --fork=$(inputs.params.fork)
- --forkName=$(inputs.params.forkName)
- --repoDir=/workspace/$(inputs.resources.repo.name)
- --upstreamName=$(inputs.params.upstreamName)
# Modify the model
- name: kpt-set
image: $(inputs.params.kpt-image)
workingDir: /workspace/$(inputs.resources.repo.name)
command:
- kpt
- cfg
- set
- /workspace/$(inputs.resources.repo.name)/Label_Microservice/deployment
- automl-model
- $(inputs.params.automl-model)
# Hydrate the manifests
- name: hydrate
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)/Label_Microservice
command:
- make
- hydrate-prod
- name: git-configure
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
script: |
#!/usr/bin/env bash
set -x
git config --global user.email label-bot@label-bot.dev
git config --global user.name "Label bot"
# Commit and push the changes
- name: create-message
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
script: |
#!/usr/bin/env bash
set -x
cat << 'EOF' >> /workspace/message.txt
[auto PR] Update model to $(inputs.params.automl-model)
Update the automl-model to $(inputs.params.automl-model)
EOF
- name: commit-push
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
script: |-
#!/usr/bin/env bash
set -x
# We need to create a symbolic link to the ssh files that Tekton sets up
ln -sf /tekton/home/.ssh /root/.ssh
prctl push \
--json-logs \
--refSpec=$(inputs.params.branchName) \
--forkName=$(inputs.params.forkName) \
--repoDir=/workspace/$(inputs.resources.repo.name) \
--messagePath=/workspace/message.txt
# TODO(jlewi): Should we make creating a PR its own task?
# How would we make the message available to it? We could get the message
# of the last commit if we checkout the repo? Is it possible to do that
# using the GitHub API?
#
- name: create-pr
image: $(inputs.params.prctl-image)
workingDir: /workspace/$(inputs.resources.repo.name)
script: |-
#!/usr/bin/env bash
set -x
# Uncomment to stop debugging
prctl pull-request \
--json-logs \
--privateKey=/secret/$(inputs.params.gitHubAppPrivateKeyFileName) \
--repo=$(inputs.resources.repo.url) \
--baseBranch=$(inputs.resources.repo.revision) \
--forkRef=$(inputs.params.forkOwner):$(inputs.params.branchName) \
--appId=$(inputs.params.gitHubAppId) \
--messagePath=/workspace/message.txt
volumeMounts:
- mountPath: /secret
name: github-bot-private-key
volumes:
- name: github-bot-private-key
secret:
secretName: $(inputs.params.gitHubAppPrivateKeySecretName)