|
| 1 | +--- |
| 2 | +apiVersion: tekton.dev/v1beta1 |
| 3 | +kind: PipelineRun |
| 4 | +metadata: |
| 5 | + name: doc-cloudflare-deploy |
| 6 | + annotations: |
| 7 | + pipelinesascode.tekton.dev/max-keep-runs: "2" |
| 8 | + pipelinesascode.tekton.dev/cancel-in-progress: "true" |
| 9 | + pipelinesascode.tekton.dev/on-cel-expression: | |
| 10 | + event == "push" && ( |
| 11 | + (target_branch == "main" && "docs/***".pathChanged()) || |
| 12 | + git_tag != "" |
| 13 | + ) |
| 14 | +spec: |
| 15 | + params: |
| 16 | + - name: repo_url |
| 17 | + value: "{{repo_url}}" |
| 18 | + - name: revision |
| 19 | + value: "{{revision}}" |
| 20 | + - name: hugo_version |
| 21 | + value: "0.146.0" |
| 22 | + - name: wrangler_version |
| 23 | + value: "4.72.0" |
| 24 | + pipelineSpec: |
| 25 | + params: |
| 26 | + - name: repo_url |
| 27 | + - name: revision |
| 28 | + - name: hugo_version |
| 29 | + - name: wrangler_version |
| 30 | + tasks: |
| 31 | + - name: deploy-doc |
| 32 | + taskSpec: |
| 33 | + workspaces: |
| 34 | + - name: source |
| 35 | + steps: |
| 36 | + - name: fetch-repo |
| 37 | + ref: |
| 38 | + resolver: http |
| 39 | + params: |
| 40 | + - name: url |
| 41 | + value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/stepactions/git-clone.yaml |
| 42 | + params: |
| 43 | + - name: output-path |
| 44 | + value: $(workspaces.source.path) |
| 45 | + - name: url |
| 46 | + value: "$(params.repo_url)" |
| 47 | + - name: revision |
| 48 | + value: "$(params.revision)" |
| 49 | + - name: cache-fetch |
| 50 | + ref: |
| 51 | + resolver: http |
| 52 | + params: |
| 53 | + - name: url |
| 54 | + value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/tasks/cache-fetch.yaml |
| 55 | + params: |
| 56 | + - name: patterns |
| 57 | + value: ["$(workspaces.source.path)/README.md"] |
| 58 | + - name: source |
| 59 | + value: oci://image-registry.openshift-image-registry.svc:5000/$(context.pipelineRun.namespace)/cache-hugo:v$(params.hugo_version) |
| 60 | + - name: cachePath |
| 61 | + value: $(workspaces.source.path)/tmp/hugo |
| 62 | + - name: workingdir |
| 63 | + value: $(workspaces.source.path) |
| 64 | + - name: hugo-build |
| 65 | + image: docker.io/golang:1.25 |
| 66 | + workingDir: $(workspaces.source.path) |
| 67 | + script: | |
| 68 | + #!/usr/bin/env bash |
| 69 | + set -xeuo pipefail |
| 70 | + git config --global --add safe.directory $(workspaces.source.path) |
| 71 | + make download-hugo HUGO_VERSION=$(params.hugo_version) |
| 72 | + hugobin=$(git rev-parse --show-toplevel)/tmp/hugo/hugo |
| 73 | + [[ -x ${hugobin} ]] || { |
| 74 | + echo "Hugo was not downloaded properly" && exit 1 |
| 75 | + } |
| 76 | + cd $(git rev-parse --show-toplevel)/docs |
| 77 | + ${hugobin} build --gc --minify |
| 78 | + - name: cloudflare-deploy |
| 79 | + image: docker.io/node:20-slim |
| 80 | + workingDir: $(workspaces.source.path) |
| 81 | + env: |
| 82 | + - name: CLOUDFLARE_API_TOKEN |
| 83 | + valueFrom: |
| 84 | + secretKeyRef: |
| 85 | + name: cloudflare-creds |
| 86 | + key: api-token |
| 87 | + - name: CLOUDFLARE_ACCOUNT_ID |
| 88 | + valueFrom: |
| 89 | + secretKeyRef: |
| 90 | + name: cloudflare-creds |
| 91 | + key: account-id |
| 92 | + script: | |
| 93 | + #!/usr/bin/env bash |
| 94 | + set -euo pipefail |
| 95 | + git_tag="{{git_tag}}" |
| 96 | + if [[ -n "${git_tag}" ]]; then |
| 97 | + branch="${git_tag}" |
| 98 | + else |
| 99 | + branch="main" |
| 100 | + fi |
| 101 | + cd docs/public |
| 102 | + npx --yes "wrangler@$(params.wrangler_version)" pages deploy . \ |
| 103 | + --project-name='pipelines-as-code' \ |
| 104 | + --branch="${branch}" |
| 105 | + - name: cache-upload |
| 106 | + ref: |
| 107 | + resolver: http |
| 108 | + params: |
| 109 | + - name: url |
| 110 | + value: https://raw.githubusercontent.com/openshift-pipelines/pipelines-as-code/refs/heads/main/.tekton/tasks/cache-upload.yaml |
| 111 | + params: |
| 112 | + - name: patterns |
| 113 | + value: ["$(workspaces.source.path)/README.md"] |
| 114 | + - name: target |
| 115 | + value: oci://image-registry.openshift-image-registry.svc:5000/$(context.pipelineRun.namespace)/cache-hugo:v$(params.hugo_version) |
| 116 | + - name: fetched |
| 117 | + value: $(steps.cache-fetch.results.fetched) |
| 118 | + - name: cachePath |
| 119 | + value: $(workspaces.source.path)/tmp/hugo |
| 120 | + - name: workingdir |
| 121 | + value: $(workspaces.source.path) |
| 122 | + - name: force-cache-upload |
| 123 | + value: "false" |
| 124 | + workspaces: |
| 125 | + - name: source |
| 126 | + workspace: source |
| 127 | + workspaces: |
| 128 | + - name: source |
| 129 | + workspaces: |
| 130 | + - name: source |
| 131 | + emptyDir: {} |
0 commit comments