1
0
mirror of https://github.com/tektoncd/catalog.git synced 2024-11-23 06:08:46 +00:00

* task: added hugo (#1)

* first submission

* changed to non npm source repo

* added params to the hugo task

* added readme

* removed platform restriction doc

* updated task and readme

* added task description

* used fully qualified registry name for docker image

* updated OWNERS

* tagged image with digest

* updated `apiVersion` to `v1` from `v1beta1`
This commit is contained in:
Sumeet Parmar 2024-02-16 10:25:12 -08:00 committed by tekton-robot
parent d080886e81
commit 962bb64bdc
6 changed files with 223 additions and 0 deletions

71
task/hugo/0.1/README.md Normal file
View File

@ -0,0 +1,71 @@
# Hugo
[Hugo](https://github.com/gohugoio/hugo) is a static site generator written in Go.
It is optimized for speed, easy use and configurability. Hugo takes a directory
with content and templates and renders them into a full html website.
This `tekton` task generates a Hugo site. For `0.1` is only supports
hugo [modules](https://gohugo.io/hugo-modules/).
## Installing the Task
You can install the task with the following command:
```bash
kubectl apply -f https://raw.githubusercontent.com/tektoncd/catalog/main/task/hugo/0.1/hugo.yaml
```
## Parameters
- **content-dir**: The directory where the content is located. (_default_: `""`)
- **minify**: Minify the output. (_default_: `false`)
- **base-url**: The base URL for the site. (_default_: `""`)
- **verbose**: Print verbose output. (_default_: `false`)
## Workspaces
- **work-dir**: The directory where `hugo` will be run. It should contain the `config.toml` file and the `content` and `layouts` directories.
## Results
- `output`: The directory where the generated site is located.
## Usage
```
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: hugo-task-test-pipeline
spec:
workspaces:
- name: work-dir
tasks:
- name: fetch-repository
taskRef:
name: git-clone
workspaces:
- name: output
workspace: work-dir
params:
- name: url
value: "https://github.com/shipit/hugotenberg.git"
- name: subdirectory
value: ""
- name: deleteExisting
value: "true"
- name: build-project
runAfter:
- fetch-repository
taskRef:
name: hugo
workspaces:
- name: work-dir
workspace: work-dir
```
## Platforms
The Task can be run on `linux/amd64` platform.

86
task/hugo/0.1/hugo.yaml Normal file
View File

@ -0,0 +1,86 @@
apiVersion: tekton.dev/v1
kind: Task
metadata:
name: hugo
labels:
app.kubernetes.io/version: "0.1"
annotations:
tekton.dev/pipelines.minVersion: "0.12.1"
tekton.dev/categories: Build Tools, Cloud
tekton.dev/tags: buildtools, cloud
tekton.dev/displayName: Hugo
tekton.dev/platforms: "linux/amd64"
spec:
description: >-
A Task that builds a Hugo site.
This task uses the Hugo static site generator to build a static site from the
content in the specified directory.
workspaces:
- name: work-dir
params:
- name: content-dir
type: string
description: The directory where the content is located
default: ""
- name: minify
type: string
description: Minify the output e.g. HTML, CSS, JS, XML
default: "false"
- name: base-url
type: string
description: The base URL for the Hugo site. By default reads from the hugo.toml or hugo.yaml
default: ""
- name: verbose
type: string
description: Verbose output
default: "false"
results:
- name: output
description: generated static site
steps:
- name: build
env:
- name: HUGO_MINIFY
value: $(params.minify)
- name: HUGO_BASEURL
value: $(params.base-url)
- name: HUGO_VERBOSE
value: $(params.verbose)
- name: HUGO_CONTENT_DIR
value: $(params.content-dir)
image: docker.io/hugomods/hugo:0.122.0@sha256:e90f2e6786969463f3475c7d5e7f031cb5dbf75a8394687d52f99d6c9d0eda0d
script: |
export HUGOCMD="hugo"
if [ "$HUGO_MINIFY" = 'true' ]; then
export HUGOCMD="${HUGOCMD} --minify"
fi
if [ "$HUGO_BASEURL" != '' ]; then
export HUGOCMD="${HUGOCMD} --baseURL $HUGO_BASEURL"
fi
if [ "$HUGO_VERBOSE" = 'true' ]; then
export HUGOCMD="${HUGOCMD} --verbose"
fi
if [ "$HUGO_CONTENT_DIR" != '' ]; then
export HUGOCMD="${HUGOCMD} --contentDir ${HUGO_CONTENT_DIR}"
fi
cd "$(workspaces.work-dir.path)" || exit
$HUGOCMD
printf "%s/public" "$(workspaces.work-dir.path)" | tee /tekton/results/output

View File

@ -0,0 +1,4 @@
#!/usr/bin/env bash
# Add git-clone
add_task git-clone latest

View File

@ -0,0 +1,10 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hugo-project-source-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 500Mi

View File

@ -0,0 +1,46 @@
apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
name: hugo-task-test-pipeline
spec:
workspaces:
- name: work-dir
tasks:
- name: fetch-repository
taskRef:
name: git-clone
workspaces:
- name: output
workspace: work-dir
params:
- name: url
value: "https://github.com/shipit/hugotenberg.git"
- name: subdirectory
value: ""
- name: deleteExisting
value: "true"
- name: build-project
runAfter:
- fetch-repository
taskRef:
name: hugo
workspaces:
- name: work-dir
workspace: work-dir
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
name: hugo-task-test-pipeline-run
spec:
pipelineRef:
name: hugo-task-test-pipeline
podTemplate:
securityContext:
fsGroup: 65532
workspaces:
- name: work-dir
persistentvolumeclaim:
claimName: hugo-project-source-pvc

6
task/hugo/OWNERS Normal file
View File

@ -0,0 +1,6 @@
approvers:
- shipit
- vdemeester
reviewers:
- shipit
- vdemeester