Skip to content

Commit

Permalink
Merge pull request #71 from bcgov/react-update
Browse files Browse the repository at this point in the history
updates to react-demo pipeline and created triggers
  • Loading branch information
calbertan authored Aug 22, 2023
2 parents 572b4a4 + 9a81ee8 commit 2a41455
Show file tree
Hide file tree
Showing 6 changed files with 151 additions and 3 deletions.
38 changes: 35 additions & 3 deletions tekton/base/pipelines/react.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,17 @@ spec:
- description: The git branch to clone.
name: branchName
type: string
- name: pathToContext
- description: Path to the file that contains the application
name: pathToContext
type: string
- name: imageTag
- description: A tag to differentiate versions of images
name: imageTag
type: string
default: v1
default: latest
- description: Whether or not runDeploy will run. Will run if set to 'true'
name: runDeploy
type: string
default: false
tasks:
- name: fetch-repo
params:
Expand All @@ -31,6 +37,7 @@ spec:
workspaces:
- name: output
workspace: shared-data

- name: react-workspace
params:
- name: CONTEXT_DIR
Expand All @@ -43,6 +50,7 @@ spec:
workspaces:
- name: source
workspace: shared-data

- name: react-build
params:
- name: CONTEXT_DIR
Expand All @@ -60,7 +68,12 @@ spec:
workspaces:
- name: source
workspace: shared-data

- name: react-deploy
when:
- input: "$(params.runDeploy)"
operator: in
values: ["true"]
params:
- name: APP_NAME
value: $(params.appName)
Expand All @@ -73,6 +86,25 @@ spec:
taskRef:
kind: Task
name: t-react-deploy

- name: react-update
when:
- input: "$(params.runDeploy)"
operator: notin
values: ["true"]
params:
- name: APP_NAME
value: $(params.appName)
- name: TAG
value: $(params.imageTag)
- name: NAMESPACE
value: $(context.pipelineRun.namespace)
runAfter:
- react-build
taskRef:
kind: Task
name: t-react-update

workspaces:
- description: |
This workspace will receive the cloned git repo and be passed
Expand Down
1 change: 1 addition & 0 deletions tekton/base/tasks/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ resources:
- git-clone.yaml
- react-workspace.yaml
- react-deploy.yaml
- react-update.yaml
- mvn-build.yaml
- mvn-sonar-scan.yaml
- npm-sonar-scan.yaml
Expand Down
34 changes: 34 additions & 0 deletions tekton/base/tasks/react-update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: react-update
labels:
app.kubernetes.io/version: "0.2"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/categories: Build Tools
tekton.dev/tags: build-tool
tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le"
spec:
params:
- name: APP_NAME
type: string
- name: TAG
type: string
description: Image tag of the imagestream
- name: NAMESPACE
type: string
description: Namespace tobe deploy
steps:
- name: deploy
args:
- set
- image
- deploymentconfig/$(params.APP_NAME)
- $(params.APP_NAME)=$(params.APP_NAME):$(params.TAG)
- '--namespace=$(params.NAMESPACE)'
command:
- oc
image: openshift/origin-cli:latest
resources: {}

1 change: 1 addition & 0 deletions tekton/base/triggers/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ resources:
- ingress.yaml
# switch to use the default serviceAccount/pipeline
- rbac.yaml
- trigger-react-build.yaml
- trigger-flask-web.yaml
- trigger-maven-build.yaml
80 changes: 80 additions & 0 deletions tekton/base/triggers/trigger-react-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerTemplate
metadata:
name: react-build-trigger
spec:
params:
- name: appName
default: simple-react
- name: repoUrl
default: https://github.com/bcgov/pipeline-templates.git
- name: branchName
default: main
- name: pathToContext
default: ./tekton/demo/simple-react
- name: imageTag
default: v1
resourcetemplates:
- apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: react-build-run-
spec:
pipelineRef:
name: p-react-build
params:
- name: appName
value: $(tt.params.appName)
- name: repoUrl
value: $(tt.params.repoUrl)
- name: branchName
value: $(tt.params.branchName)
- name: pathToContext
value: $(tt.params.pathToContext)
- name: imageTag
value: $(tt.params.imageTag)
workspaces:
- name: shared-data
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 100Mi
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: EventListener
metadata:
name: react-build-event-listener
spec:
serviceAccountName: pipeline
triggers:
- name: github-listener
interceptors:
- github:
secretRef:
secretName: github-webhook-secret
secretKey: secretToken
eventTypes:
- pull_request
- push
bindings:
- ref: react-build-trigger-binding
template:
ref: react-build-trigger
---
apiVersion: triggers.tekton.dev/v1alpha1
kind: TriggerBinding
metadata:
name: react-build-trigger-binding
spec:
params:
- name: branchName
value: $(body.ref)
- name: repoUrl
value: $(body.repository.url)
- name: contenttype
value: $(header.Content-Type)
- name: imageTag
value: $(body.head_commit.message)
Empty file removed test.yaml
Empty file.

0 comments on commit 2a41455

Please sign in to comment.