feat: automate lolympus staging delivery

This commit is contained in:
dahyeon committed 2026-07-18 07:52:56 +00:00
1 parent 0a43455acf
commit 73d42eb61d
6 files changed
+229 -4

No files matched your search

+15 -1
View File
@@ -71,6 +71,21 @@ rules:
- get - get
- list - list
- watch - watch
- apiGroups:
- ""
resources:
- serviceaccounts
resourceNames:
- lolympus-pipeline
verbs:
- impersonate
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch
- apiGroups: - apiGroups:
- "" - ""
resources: resources:
@@ -91,4 +106,3 @@ roleRef:
subjects: subjects:
- kind: ServiceAccount - kind: ServiceAccount
name: lolympus-event-listener name: lolympus-event-listener
@@ -0,0 +1,23 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: lolympus-main-webhook
annotations:
cert-manager.io/cluster-issuer: letsencrypt-prod
spec:
ingressClassName: haproxy
tls:
- hosts:
- tekton-hook.dahyeon.us
secretName: lolympus-main-webhook-tls
rules:
- host: tekton-hook.dahyeon.us
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: el-lolympus-main
port:
number: 8080
@@ -7,6 +7,9 @@ resources:
- foundation.yaml - foundation.yaml
- infisical-secret.yaml - infisical-secret.yaml
- tasks.yaml - tasks.yaml
- pipeline.yaml
- trigger.yaml
- ingress.yaml
labels: labels:
- includeSelectors: false - includeSelectors: false
@@ -0,0 +1,89 @@
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: lolympus-staging
spec:
description: Validate, publish, and deploy a main-branch revision to staging.
params:
- name: git-revision
type: string
- name: image-tag
type: string
results:
- name: image-digest
description: Immutable API image digest.
value: $(tasks.build-api.results.image-digest)
- name: gitops-commit
description: service-state commit applied to staging.
value: $(tasks.update-gitops.results.gitops-commit)
workspaces:
- name: source
- name: gitea-credentials
- name: harbor-dockerconfig
tasks:
- name: clone
taskRef:
name: lolympus-clone
params:
- name: revision
value: $(params.git-revision)
workspaces:
- name: source
workspace: source
- name: credentials
workspace: gitea-credentials
- name: quality
runAfter:
- clone
taskRef:
name: lolympus-quality
workspaces:
- name: source
workspace: source
- name: build-api
runAfter:
- quality
taskRef:
name: lolympus-build-image
params:
- name: image
value: registry.dahyeon.us/lolympus/lolympus-tournament-support:$(params.image-tag)
workspaces:
- name: source
workspace: source
- name: dockerconfig
workspace: harbor-dockerconfig
- name: assert-latest
runAfter:
- build-api
taskRef:
name: lolympus-assert-latest
params:
- name: revision
value: $(params.git-revision)
workspaces:
- name: credentials
workspace: gitea-credentials
- name: deploy-web
runAfter:
- assert-latest
taskRef:
name: lolympus-deploy-cloudflare
workspaces:
- name: source
workspace: source
- name: update-gitops
runAfter:
- deploy-web
taskRef:
name: lolympus-update-gitops
params:
- name: revision
value: $(params.git-revision)
- name: image-tag
value: $(params.image-tag)
workspaces:
- name: source
workspace: source
- name: credentials
workspace: gitea-credentials
+2 -3
View File
@@ -152,14 +152,13 @@ spec:
script: | script: |
#!/bin/sh #!/bin/sh
set -eu set -eu
mkdir -p .ci
buildctl-daemonless.sh build \ buildctl-daemonless.sh build \
--frontend dockerfile.v0 \ --frontend dockerfile.v0 \
--local context=. \ --local context=. \
--local dockerfile=. \ --local dockerfile=. \
--opt filename=Dockerfile \ --opt filename=Dockerfile \
--output "type=image,name=$(params.image),push=true" \ --output "type=image,name=$(params.image),push=true" \
--metadata-file .ci/buildkit-metadata.json --metadata-file "$(results.image-digest.path)"
- name: record-digest - name: record-digest
image: docker.io/mikefarah/yq:4.47.2@sha256:76def1f56f456ecc1c3173ea275218ee17139bc2018c5a07887b15afd88ec03e image: docker.io/mikefarah/yq:4.47.2@sha256:76def1f56f456ecc1c3173ea275218ee17139bc2018c5a07887b15afd88ec03e
workingDir: $(workspaces.source.path) workingDir: $(workspaces.source.path)
@@ -169,7 +168,7 @@ spec:
script: | script: |
#!/bin/sh #!/bin/sh
set -eu set -eu
DIGEST="$$(yq -r '."containerimage.digest"' .ci/buildkit-metadata.json)" DIGEST="$$(yq -r '."containerimage.digest"' "$(results.image-digest.path)")"
if [ -z "$DIGEST" ] || [ "$DIGEST" = "null" ]; then if [ -z "$DIGEST" ] || [ "$DIGEST" = "null" ]; then
echo "BuildKit did not return an image digest" >&2 echo "BuildKit did not return an image digest" >&2
exit 1 exit 1
@@ -0,0 +1,97 @@
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerBinding
metadata:
name: lolympus-main
spec:
params:
- name: git-revision
value: $(body.after)
---
apiVersion: triggers.tekton.dev/v1beta1
kind: TriggerTemplate
metadata:
name: lolympus-main
spec:
params:
- name: git-revision
resourcetemplates:
- apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
generateName: lolympus-staging-
labels:
app.kubernetes.io/name: lolympus-tournament-support
app.kubernetes.io/part-of: lolympus-ci
spec:
pipelineRef:
name: lolympus-staging
params:
- name: git-revision
value: $(tt.params.git-revision)
- name: image-tag
value: sha-$(tt.params.git-revision)
taskRunTemplate:
serviceAccountName: lolympus-pipeline
podTemplate:
securityContext:
fsGroup: 1000
fsGroupChangePolicy: OnRootMismatch
workspaces:
- name: source
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
storageClassName: local-path
resources:
requests:
storage: 10Gi
- name: gitea-credentials
secret:
secretName: lolympus-gitea
items:
- key: username
path: username
- key: password
path: password
- name: harbor-dockerconfig
secret:
secretName: lolympus-harbor
items:
- key: .dockerconfigjson
path: config.json
timeouts:
pipeline: 45m
tasks: 40m
---
apiVersion: triggers.tekton.dev/v1beta1
kind: EventListener
metadata:
name: lolympus-main
spec:
serviceAccountName: lolympus-event-listener
triggers:
- name: main-push
interceptors:
- ref:
name: github
params:
- name: secretRef
value:
secretName: lolympus-webhook
secretKey: secretToken
- name: eventTypes
value:
- push
- ref:
name: cel
params:
- name: filter
value: >-
body.repository.full_name == 'dahyeon/lolympus-tournament-support' &&
body.ref == 'refs/heads/main' &&
body.after.matches('^[0-9a-f]{40}$')
bindings:
- ref: lolympus-main
template:
ref: lolympus-main