mirror of
https://github.com/khuedoan/homelab.git
synced 2025-03-09 04:09:38 +07:00
feat(tekton): add pull request workflow
This commit is contained in:
parent
22a3ccd331
commit
220e5c5480
@ -1,7 +1,7 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Pipeline
|
||||
metadata:
|
||||
name: homelab
|
||||
name: master
|
||||
spec:
|
||||
workspaces:
|
||||
- name: shared-data
|
||||
@ -21,23 +21,7 @@ spec:
|
||||
workspace: shared-data
|
||||
params:
|
||||
- name: url
|
||||
value: http://gitea-http.gitea:3000/ops/homelab
|
||||
value: $(params.git_url)
|
||||
- name: revision
|
||||
value: master
|
||||
- name: pre-commit
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: shared-data
|
||||
taskSpec:
|
||||
workspaces:
|
||||
- name: source
|
||||
stepTemplate:
|
||||
image: nixos/nix:latest
|
||||
workingDir: /workspace/source
|
||||
steps:
|
||||
- name: run
|
||||
command:
|
||||
- nix-shell
|
||||
- --command
|
||||
args:
|
||||
- "pre-commit run --color=always"
|
||||
value: $(params.git_revision)
|
||||
# TODO add tests here
|
||||
|
43
.ci/pull-request.yaml
Normal file
43
.ci/pull-request.yaml
Normal file
@ -0,0 +1,43 @@
|
||||
apiVersion: tekton.dev/v1beta1
|
||||
kind: Pipeline
|
||||
metadata:
|
||||
name: pull-request
|
||||
spec:
|
||||
workspaces:
|
||||
- name: shared-data
|
||||
tasks:
|
||||
- name: git-clone
|
||||
taskRef:
|
||||
resolver: hub
|
||||
params:
|
||||
- name: kind
|
||||
value: task
|
||||
- name: name
|
||||
value: git-clone
|
||||
- name: version
|
||||
value: "0.7"
|
||||
workspaces:
|
||||
- name: output
|
||||
workspace: shared-data
|
||||
params:
|
||||
- name: url
|
||||
value: $(params.git_url)
|
||||
- name: revision
|
||||
value: $(params.git_revision)
|
||||
- name: pre-commit
|
||||
workspaces:
|
||||
- name: source
|
||||
workspace: shared-data
|
||||
taskSpec:
|
||||
workspaces:
|
||||
- name: source
|
||||
stepTemplate:
|
||||
image: nixos/nix:latest
|
||||
workingDir: /workspace/source
|
||||
steps:
|
||||
- name: run
|
||||
command:
|
||||
- nix-shell
|
||||
- --command
|
||||
args:
|
||||
- "pre-commit run --color=always"
|
@ -18,3 +18,4 @@ resources:
|
||||
# Pre-defined workflows
|
||||
- workflows/webhook-secret.yaml
|
||||
- workflows/master.yaml
|
||||
- workflows/pull-request.yaml
|
||||
|
44
platform/tekton-pipelines/workflows/pull-request.yaml
Normal file
44
platform/tekton-pipelines/workflows/pull-request.yaml
Normal file
@ -0,0 +1,44 @@
|
||||
apiVersion: workflows.tekton.dev/v1alpha1
|
||||
kind: Workflow
|
||||
metadata:
|
||||
name: pull-request
|
||||
namespace: tekton-workflows
|
||||
spec:
|
||||
triggers:
|
||||
- event:
|
||||
type: pull_request
|
||||
secret:
|
||||
secretName: webhook-secret
|
||||
secretKey: token
|
||||
bindings:
|
||||
- name: git_url
|
||||
value: $(body.repository.clone_url)
|
||||
- name: git_revision
|
||||
value: $(body.head.sha)
|
||||
params:
|
||||
- name: git_url
|
||||
# TODO don't need default, but invalid mem address if remove this
|
||||
default: https://git.khuedoan.com/foo/bar
|
||||
- name: git_revision
|
||||
default: master
|
||||
pipelineRef:
|
||||
resolver: git
|
||||
params:
|
||||
# TODO ???
|
||||
# supposed to be param. or body., looks like it's not working in v1alpha1 yet
|
||||
- name: url
|
||||
value: $(tt.params.git_url)
|
||||
- name: revision
|
||||
value: $(tt.params.git_revision)
|
||||
- name: pathInRepo
|
||||
value: .ci/pull-request.yaml
|
||||
workspaces:
|
||||
- name: shared-data
|
||||
volumeClaimTemplate:
|
||||
spec:
|
||||
storageClassName: longhorn
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 128Mi
|
Loading…
Reference in New Issue
Block a user