ci: build pipeline rewrite

This commit is contained in:
Khue Doan 2022-05-14 19:04:46 +07:00
parent cca6e61c5b
commit 7b1afcc55c
4 changed files with 76 additions and 76 deletions

View File

@ -6,7 +6,8 @@ spec:
workspaces:
- name: shared-data
tasks:
- name: fetch-repo
- name: git-clone
taskRef:
name: git-clone
workspaces:
@ -17,29 +18,96 @@ spec:
value: http://gitea-http.gitea:3000/ops/homelab
- name: revision
value: master
- name: lint
- name: tools
runAfter:
- fetch-repo
- git-clone
workspaces:
- name: source
workspace: shared-data
# TODO secure registry
# - name: dockerconfig
# workspace: dockerconfig
taskRef:
name: lint
name: kaniko
params:
- name: CONTEXT
value: ./tools
- name: IMAGE
value: registry.khuedoan.com/tools:latest
- name: EXTRA_ARGS
value:
- --cache=true
# TODO lint
- name: metal
runAfter:
- tools
workspaces:
- name: source
workspace: shared-data
taskSpec:
workspaces:
- name: source
stepTemplate:
image: registry.khuedoan.com/tools:latest
workingDir: /workspace/source/metal
command:
- make
steps:
- name: cluster
args:
- cluster
- name: bootstrap
runAfter:
- tools
workspaces:
- name: source
workspace: shared-data
taskSpec:
workspaces:
- name: source
stepTemplate:
image: registry.khuedoan.com/tools:latest
workingDir: /workspace/source/bootstrap
command:
- make
steps:
- name: argocd
args:
- argocd
- name: root
args:
- root
- name: external
runAfter:
- fetch-repo
- tools
workspaces:
- name: source
workspace: shared-data
taskRef:
name: terraform-external
taskSpec:
workspaces:
- name: source
stepTemplate:
image: registry.khuedoan.com/tools:latest
workingDir: /workspace/source/external
command:
- make
steps:
- name: plan
args:
- plan
- name: apply
args:
- apply
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: homelab
spec:
serviceAccountName: terraform-sa
pipelineRef:
name: homelab
workspaces:

View File

@ -1,36 +0,0 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: terraform-external
spec:
workspaces:
- name: source
stepTemplate:
image: hashicorp/terraform:1.1.7
workingDir: /workspace/source/external
volumeMounts:
- name: terraform-secrets
mountPath: /root/.terraform.d/credentials.tfrc.json
subPath: credentials.tfrc.json
- name: terraform-secrets
mountPath: /workspace/source/external/terraform.tfvars
subPath: terraform.tfvars
command:
- terraform
volumes:
- name: terraform-secrets
secret:
secretName: terraform-secrets
steps:
- name: init
args:
- init
- name: plan
args:
- plan
- -out=tfplan
- name: apply
args:
- apply
- -auto-approve
- tfplan

View File

@ -7,6 +7,4 @@ resources:
- https://raw.githubusercontent.com/tektoncd/catalog/main/task/gitleaks/0.1/gitleaks.yaml
- https://raw.githubusercontent.com/tektoncd/catalog/main/task/kaniko/0.5/kaniko.yaml
- https://raw.githubusercontent.com/tektoncd/catalog/main/task/pull-request/0.1/pull-request.yaml
- external.yaml
- lint.yaml
- check-git-files-changed.yaml

View File

@ -1,30 +0,0 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: lint
spec:
workspaces:
- name: source
steps:
- name: ansible
image: cytopia/ansible-lint
workingDir: /workspace/source/metal
command:
- ansible-lint
args:
- -v
- name: yaml
image: cytopia/yamllint
command:
- yamllint
args:
- .
- name: terraform
image: hashicorp/terraform:1.1.7
command:
- terraform
args:
- fmt
- -recursive
- -check
- -diff