Skip to content

Commit 22232c2

Browse files
rajnish-jaisrajnish-cloudbees
authored andcommitted
Add PAC Repository CRs for tektoncd/triggers and tektoncd/results
Adds releases-triggers and releases-results namespaces with Repository CRs so PAC can dispatch release PipelineRuns for: - tektoncd/triggers (see tektoncd/triggers#2062) - tektoncd/results (see tektoncd/results#1373) Follows the same pattern as the existing chains, pipeline, pruner, operator, and cli CRs.
0 parents  commit 22232c2

1,287 files changed

Lines changed: 318990 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
# This action sets up a complete Tekton CI/CD infrastructure for nightly builds
2+
# with the following components:
3+
#
4+
# 1. Kubernetes cluster using Kind for local development/testing
5+
# 2. Tekton Pipelines for workflow orchestration
6+
# 3. Tekton CLI (tkn) for pipeline management
7+
# 4. Git resolver configuration for GitHub repository access
8+
# 5. Required secrets and service accounts for:
9+
# - OCI bucket access (release artifacts)
10+
# - GHCR authentication (container registry)
11+
# - Git operations (repository cloning)
12+
# 6. RBAC configuration for pipeline execution
13+
# 7. Tekton Chains with Sigstore integration for:
14+
# - Supply chain security
15+
# - Artifact signing and verification
16+
# - Transparency logging
17+
# 8. GitHub OIDC token management for secure authentication
18+
19+
name: Tekton Nightly Build Infra
20+
description: |
21+
Sets up Tekton nightly build infrastructure.
22+
inputs:
23+
kubernetes_version:
24+
description: 'Kubernetes version to test with'
25+
required: false
26+
default: 'v1.33.x'
27+
image_registry_user:
28+
description: 'Image registry user'
29+
required: false
30+
default: 'tekton-robot'
31+
ghcr_token:
32+
description: 'GHCR token'
33+
required: true
34+
oci_api_key:
35+
description: 'OCI API key'
36+
required: true
37+
oci_fingerprint:
38+
description: 'OCI fingerprint'
39+
required: true
40+
oci_tenancy_ocid:
41+
description: 'OCI tenancy OCID'
42+
required: true
43+
oci_user_ocid:
44+
description: 'OCI user OCID'
45+
required: true
46+
oci_region:
47+
description: 'OCI region'
48+
required: true
49+
50+
runs:
51+
using: "composite"
52+
steps:
53+
# Step 1: Set up Kubernetes cluster with Kind
54+
- name: Set up Kind cluster
55+
uses: chainguard-dev/actions/setup-kind@be7b31a01af8ce7228fe901326f1d223fb788e14 # v1.4.12
56+
with:
57+
k8s-version: ${{ inputs.kubernetes_version }}
58+
59+
# Step 2: Install Tekton Pipelines
60+
- name: Set up Tekton
61+
uses: tektoncd/actions/setup-tektoncd@f163fb3432ae7767d14bfa9b17e3975c7bd9ea06
62+
with:
63+
pipeline_version: v1.4.0
64+
setup_registry: "true"
65+
patch_etc_hosts: "true"
66+
67+
# Step 3: Install Tekton CLI
68+
- name: Install tkn CLI
69+
uses: tektoncd/actions/setup-tektoncd-cli@dd92514472167b361de1c95fd31fc2ef83c282ec
70+
with:
71+
version: v0.42.0
72+
73+
# Step 4: Configure Git Resolver for GitHub access
74+
- name: Configure Tekton Git Resolver
75+
env:
76+
GITHUB_TOKEN: ${{ inputs.ghcr_token }}
77+
run: |
78+
set -euo pipefail
79+
# Create git resolver secret in tekton-pipelines-resolvers namespace
80+
kubectl create secret generic git-resolver-secret \
81+
--from-literal=token="${GITHUB_TOKEN}" \
82+
-n tekton-pipelines-resolvers || true
83+
kubectl annotate secret git-resolver-secret \
84+
tekton.dev/git-0=github.com \
85+
-n tekton-pipelines-resolvers || true
86+
# Create git resolver secret in default namespace
87+
kubectl create secret generic git-resolver-secret \
88+
--from-literal=token="${GITHUB_TOKEN}" \
89+
-n default || true
90+
kubectl annotate secret git-resolver-secret \
91+
tekton.dev/git-0=github.com \
92+
-n default || true
93+
# Configure git resolver to use the secret
94+
kubectl patch configmap git-resolver-config -n tekton-pipelines-resolvers --patch='
95+
data:
96+
api-token-secret-name: "git-resolver-secret"
97+
api-token-secret-key: "token"
98+
' || true
99+
# Enable CEL in when expressions for advanced pipeline logic
100+
kubectl patch configmap feature-flags -n tekton-pipelines --patch='
101+
data:
102+
enable-cel-in-whenexpression: "true"
103+
' || true
104+
shell: bash
105+
106+
# Step 5: Create required secrets and PVC template
107+
- name: Create secrets, service account and PVC template
108+
env:
109+
GHCR_TOKEN: ${{ inputs.ghcr_token }}
110+
IMAGE_REGISTRY_USER: ${{ inputs.image_registry_user }}
111+
OCI_API_KEY: ${{ inputs.oci_api_key }}
112+
OCI_FINGERPRINT: ${{ inputs.oci_fingerprint }}
113+
OCI_TENANCY_OCID: ${{ inputs.oci_tenancy_ocid }}
114+
OCI_USER_OCID: ${{ inputs.oci_user_ocid }}
115+
OCI_REGION: ${{ inputs.oci_region }}
116+
run: |
117+
set -euo pipefail
118+
trap 'rm -f /tmp/oci_* /tmp/credentials' EXIT
119+
120+
# Create Oracle Cloud credentials secret for release bucket access
121+
echo "${OCI_API_KEY}" > /tmp/oci_api_key.pem
122+
echo "${OCI_FINGERPRINT}" > /tmp/oci_fingerprint
123+
echo "${OCI_TENANCY_OCID}" > /tmp/oci_tenancy_ocid
124+
echo "${OCI_USER_OCID}" > /tmp/oci_user_ocid
125+
echo "${OCI_REGION}" > /tmp/oci_region
126+
kubectl create secret generic release-secret \
127+
--from-file=oci_api_key.pem=/tmp/oci_api_key.pem \
128+
--from-file=fingerprint=/tmp/oci_fingerprint \
129+
--from-file=tenancy_ocid=/tmp/oci_tenancy_ocid \
130+
--from-file=user_ocid=/tmp/oci_user_ocid \
131+
--from-file=region=/tmp/oci_region
132+
133+
# Create Kubernetes secret for GHCR authentication
134+
echo "${GHCR_TOKEN}" > /tmp/credentials
135+
kubectl create secret generic ghcr-creds \
136+
--from-file=credentials=/tmp/credentials
137+
# Create PVC template for persistent storage
138+
cat > workspace-template.yaml << EOF
139+
spec:
140+
accessModes:
141+
- ReadWriteOnce
142+
resources:
143+
requests:
144+
storage: 1Gi
145+
EOF
146+
shell: bash
147+
148+
# Step 6: Set up RBAC and ServiceAccount
149+
- name: Apply ServiceAccount, RBAC, and related resources
150+
run: |
151+
set -euo pipefail
152+
kubectl apply -f - <<EOF
153+
apiVersion: v1
154+
kind: ServiceAccount
155+
metadata:
156+
name: release-right-meow
157+
secrets:
158+
- name: release-secret
159+
- name: git-resolver-secret
160+
- name: ghcr-creds
161+
---
162+
apiVersion: v1
163+
kind: Secret
164+
metadata:
165+
name: kube-api-secret
166+
annotations:
167+
kubernetes.io/service-account.name: release-right-meow
168+
type: kubernetes.io/service-account-token
169+
---
170+
kind: Role
171+
apiVersion: rbac.authorization.k8s.io/v1
172+
metadata:
173+
name: pipeline-role
174+
rules:
175+
- apiGroups: [""]
176+
resources: ["services", "configmaps", "secrets"]
177+
verbs: ["get", "create", "update", "patch", "list"]
178+
- apiGroups: ["apps"]
179+
resources: ["deployments"]
180+
verbs: ["get", "create", "update", "patch", "list"]
181+
- apiGroups: ["tekton.dev"]
182+
resources: ["pipelines", "pipelineruns", "tasks", "taskruns"]
183+
verbs: ["get", "create", "update", "patch", "list"]
184+
- apiGroups: [""]
185+
resources: ["pods", "pods/log"]
186+
verbs: ["get", "list"]
187+
---
188+
apiVersion: rbac.authorization.k8s.io/v1
189+
kind: RoleBinding
190+
metadata:
191+
name: pipeline-role-binding
192+
roleRef:
193+
apiGroup: rbac.authorization.k8s.io
194+
kind: Role
195+
name: pipeline-role
196+
subjects:
197+
- kind: ServiceAccount
198+
name: release-right-meow
199+
EOF
200+
shell: bash
201+
202+
# Step 7: Install and configure Tekton Chains with Sigstore
203+
- name: Install Tekton Chains with Fulcio enabled
204+
run: |
205+
set -euo pipefail
206+
# Install Tekton Chains from latest release
207+
kubectl apply -f https://infra.tekton.dev/tekton-releases/chains/previous/v0.25.1/release.yaml -n tekton-chains
208+
209+
# Configure Chains for Sigstore integration with Fulcio and Rekor
210+
kubectl patch configmap chains-config -n tekton-chains --type merge -p '
211+
{
212+
"data": {
213+
"artifacts.taskrun.format": "in-toto",
214+
"artifacts.oci.format": "simplesigning",
215+
"artifacts.oci.storage": "oci",
216+
"artifacts.oci.signer": "x509",
217+
"signers.x509.fulcio.enabled": "true",
218+
"signers.x509.fulcio.address": "https://fulcio.sigstore.dev",
219+
"signers.x509.fulcio.issuer": "https://token.actions.githubusercontent.com",
220+
"transparency.enabled": "true",
221+
"transparency.url": "https://rekor.sigstore.dev"
222+
}
223+
}'
224+
# Restart controller to apply new configuration
225+
kubectl rollout restart deployment tekton-chains-controller -n tekton-chains
226+
227+
echo "Waiting for Tekton Chains controller to be ready..."
228+
kubectl wait --for=condition=ready pod -l app=tekton-chains-controller -n tekton-chains --timeout=300s
229+
echo "Tekton Chains is ready!"
230+
shell: bash
231+
232+
# Step 8: Set up GitHub OIDC token for Sigstore authentication.
233+
# The token has expiry of 5 mins hence it is continuously refreshed in the background.
234+
- name: Retrieve and refresh GitHub OIDC token in cluster
235+
shell: bash
236+
run: |
237+
set -euo pipefail
238+
239+
# Function to mint and update OIDC token
240+
mint_and_update() {
241+
echo "Minting fresh OIDC token..."
242+
token=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
243+
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=sigstore" | jq -r .value)
244+
245+
echo "::add-mask::$token"
246+
247+
# Create or update secret in tekton-chains namespace
248+
kubectl create secret generic github-oidc-token \
249+
-n tekton-chains \
250+
--from-literal=oidc-token="$token" \
251+
--dry-run=client -o yaml | kubectl apply -f -
252+
253+
echo "Token refreshed at $(date)"
254+
}
255+
256+
# Background function to refresh token every 5 minutes
257+
refresh_loop() {
258+
while true; do
259+
sleep 280 # 20 seconds to 5 minutes
260+
mint_and_update
261+
done
262+
}
263+
264+
# Initial token mint
265+
mint_and_update
266+
267+
# Patch chains-controller to mount the OIDC token secret
268+
echo "Ensuring chains-controller mounts the OIDC token secret..."
269+
kubectl patch deployment tekton-chains-controller -n tekton-chains --type='json' -p='[
270+
{
271+
"op": "replace",
272+
"path": "/spec/template/spec/volumes/1",
273+
"value": { "name": "oidc-info", "secret": { "secretName": "github-oidc-token" } }
274+
}
275+
]'
276+
277+
kubectl rollout status deployment tekton-chains-controller -n tekton-chains --timeout=120s
278+
279+
# Start background token refresher
280+
refresh_loop &
281+
echo "Background token refresher running..."

0 commit comments

Comments
 (0)