chore: aligned pipelines, tasks & rbac

This commit is contained in:
eding 2026-02-12 12:50:59 +01:00
parent 4f5872c707
commit c018da3747
4 changed files with 42 additions and 9 deletions

View file

@ -9,7 +9,6 @@ spec:
- name: git-url - name: git-url
- name: git-revision - name: git-revision
- name: pr-number - name: pr-number
default: ""
- name: event-type - name: event-type
workspaces: workspaces:
- name: shared-data - name: shared-data
@ -26,9 +25,16 @@ spec:
- name: revision - name: revision
value: $(params.git-revision) value: $(params.git-revision)
# 2. Build and Push Image (using standard Kaniko) - name: build-app
- name: build-and-push
runAfter: [fetch-repository] runAfter: [fetch-repository]
taskRef:
name: build-node
workspaces:
- name: source
workspace: shared-data
- name: build-and-push-image
runAfter: [build-app]
taskRef: taskRef:
name: kaniko name: kaniko
workspaces: workspaces:
@ -38,13 +44,12 @@ spec:
- name: IMAGE - name: IMAGE
value: "ghcr.io/pingu-studio/$(params.app-name):$(params.git-revision)" value: "ghcr.io/pingu-studio/$(params.app-name):$(params.git-revision)"
# 3. PREVIEW: Runs only on PR
- name: deploy-preview - name: deploy-preview
when: when:
- input: "$(params.event-type)" - input: "$(params.event-type)"
operator: in operator: in
values: ["pull_request"] values: ["pull_request"]
runAfter: [build-and-push] runAfter: [build-and-push-image]
taskRef: taskRef:
name: manage-preview name: manage-preview
workspaces: workspaces:
@ -54,8 +59,8 @@ spec:
- name: app-name - name: app-name
value: $(params.app-name) value: $(params.app-name)
- name: pr-number - name: pr-number
value: "$(params.pr-number)" value: $(params.pr-number)
- name: image-tag - name: image-tag
value: "$(params.git-revision)" value: $(params.git-revision)
- name: action - name: action
value: "apply" value: "apply"

View file

@ -3,6 +3,10 @@ kind: ServiceAccount
metadata: metadata:
name: tekton-triggers-sa name: tekton-triggers-sa
namespace: tekton-pipelines namespace: tekton-pipelines
secrets:
- name: gh-auth-tekton-pipelines
imagePullSecrets:
- name: ghcr-auth
--- ---
apiVersion: rbac.authorization.k8s.io/v1 apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole kind: ClusterRole

22
tasks/build-node.yaml Normal file
View file

@ -0,0 +1,22 @@
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: build-node
namespace: tekton-pipelines
spec:
workspaces:
- name: source
steps:
- name: build
image: node:20-bookworm
workingDir: $(workspaces.source.path)
script: |
#!/bin/bash
if [ -f ".tekton/build.sh" ]; then
echo "Found custom build script. Executing..."
/bin/bash .tekton/build.sh
else
echo "No .tekton/build.sh found! Falling back to default build."
npm install
npm run build
fi

View file

@ -11,11 +11,13 @@ spec:
type: string type: string
- name: revision - name: revision
type: string type: string
default: main
steps: steps:
- name: clone - name: clone
image: alpine/git image: alpine/git:latest
script: | script: |
#!/bin/sh
# Tekton automatically mounts secrets with tekton.dev/git annotations
# into a shared git credentials file.
git clone $(params.url) $(workspaces.output.path) git clone $(params.url) $(workspaces.output.path)
cd $(workspaces.output.path) cd $(workspaces.output.path)
git checkout $(params.revision) git checkout $(params.revision)