Skip to content

Commit

Permalink
use stepactions for doc.yaml
Browse files Browse the repository at this point in the history
use stepactions and use cache stepaction to cache the hugo build.

Signed-off-by: Chmouel Boudjnah <[email protected]>
  • Loading branch information
chmouel committed Oct 17, 2024
1 parent 2e43169 commit 8ad92e0
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 27 deletions.
77 changes: 52 additions & 25 deletions .tekton/doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,48 @@ spec:
value: "{{repo_url}}"
- name: revision
value: "{{revision}}"
- name: hugo_version
value: "0.96.0"
pipelineSpec:
params:
- name: repo_url
- name: revision
- name: hugo_version
tasks:
- name: fetchit
params:
- name: url
value: $(params.repo_url)
- name: revision
value: $(params.revision)
- name: depth
value: "1000000"
taskRef:
name: git-clone
workspaces:
- name: output
workspace: source
- name: build-doc
runAfter:
- fetchit
taskSpec:
workspaces:
- name: source
steps:
- name: fetch-repo
ref:
resolver: http
params:
- name: url
value: https://raw.githubusercontent.com/tektoncd/catalog/main/stepaction/git-clone/0.1/git-clone.yaml
params:
- name: output-path
value: $(workspaces.source.path)
- name: url
value: "$(params.repo_url)"
- name: revision
value: "$(params.revision)"
- name: cache-fetch
ref:
resolver: http
params:
- name: url
value: https://raw.githubusercontent.com/openshift-pipelines/tekton-caches/main/tekton/cache-fetch.yaml
params:
- name: patterns
value: ["$(workspaces.source.path)/README.md"]
- name: source
value: oci://image-registry.openshift-image-registry.svc:5000/$(context.pipelineRun.namespace)/cache-hugo:v$(params.hugo_version)
- name: cachePath
value: $(workspaces.source.path)/tmp/hugo
- name: workingdir
value: $(workspaces.source.path)

- name: hugo-gen
image: golang:1.22
workingDir: $(workspaces.source.path)
Expand All @@ -52,8 +69,8 @@ spec:
#!/usr/bin/env bash
set -xeuo pipefail
git config --global --add safe.directory $(workspaces.source.path)
make download-hugo
hugobin=$(git rev-parse --show-toplevel)/tmp/hugo
make download-hugo HUGO_VERSION=$(params.hugo_version)
hugobin=$(git rev-parse --show-toplevel)/tmp/hugo/hugo
[[ -x ${hugobin} ]] || {
echo "Hugo was not downloaded properly" && exit 1
}
Expand Down Expand Up @@ -90,18 +107,28 @@ spec:
set +x
curl -H "Authorization: Bearer ${HUB_TOKEN}" -H 'Accept: application/vnd.github.v3+json' -X POST https://api.github.com/repos/{{repo_owner}}/{{repo_name}}/statuses/{{revision}} -d \
"{\"state\": \"success\", \"target_url\": \"${UPLOADER_PUBLIC_URL}/docs/{{ pull_request_number }}\", \"description\": \"Generated with brio.\", \"context\": \"Pipelines as Code Preview URL\"}"
- name: cache-upload
ref:
resolver: http
params:
- name: url
value: https://raw.githubusercontent.com/openshift-pipelines/tekton-caches/main/tekton/cache-upload.yaml
params:
- name: patterns
value: ["$(workspaces.source.path)/README.md"]
- name: target
value: oci://image-registry.openshift-image-registry.svc:5000/$(context.pipelineRun.namespace)/cache-hugo:v$(params.hugo_version)
- name: cachePath
value: $(workspaces.source.path)/tmp/hugo
- name: workingdir
value: $(workspaces.source.path)
- name: force-cache-upload
value: "false"
workspaces:
- name: source
workspace: source
workspaces:
- name: source
workspaces:
- name: source
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
emptyDir: {}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ GO_TEST_FLAGS +=
SHELL := bash
TOPDIR := $(shell git rev-parse --show-toplevel)
TMPDIR := $(TOPDIR)/tmp
HUGO_BIN := $(TMPDIR)/hugo
HUGO_BIN := $(TMPDIR)/hugo/hugo
PY_FILES := $(shell find . -type f -regex ".*\.py" -print)
SH_FILES := $(shell find hack/ -type f -regex ".*\.sh" -print)
YAML_FILES := $(shell find . -not -regex '^./vendor/.*' -type f -regex ".*y[a]ml" -print)
Expand Down Expand Up @@ -195,7 +195,7 @@ generated: update-golden fumpt ## generate all files that needs to be generated

.PHONY: download-hugo
download-hugo:
@./hack/download-hugo.sh $(HUGO_VERSION) $(TMPDIR)
./hack/download-hugo.sh $(HUGO_VERSION) $(TMPDIR)/hugo

.PHONY: clean
clean: ## clean build artifacts
Expand Down

0 comments on commit 8ad92e0

Please sign in to comment.