Skip to content

Commit bae0107

Browse files
committed
feat: migrate docs deployment to custom domain
- Replace the uploader-based doc preview pipeline with a new deployment pipeline using Cloudflare Pages - Add post-preview-status step to post the preview URL as a GitHub commit status on PRs - Update all documentation URLs from branch-based subdomains to the new custom domain (docs.pipelinesascode.com) - Update goreleaser release notes URL to use docs.pipelinesascode.com - Simplify footer version switcher to use path-based routing instead of subdomain-based routing - Remove unused generate-releasenotes.py script Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
1 parent 2e9af6c commit bae0107

File tree

6 files changed

+60
-549
lines changed

6 files changed

+60
-549
lines changed

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ release:
7474
7575
The documentation for this release is available here :
7676
77-
https://release-{{ replace .Tag "." "-" }}.pipelines-as-code.pages.dev
77+
https://docs.pipelinesascode.com/{{ .Tag }}
7878
7979
homebrew_casks:
8080
- name: tektoncd-pac

.tekton/doc.yaml

Lines changed: 54 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
apiVersion: tekton.dev/v1beta1
33
kind: PipelineRun
44
metadata:
5-
name: doc-generation
5+
name: doc-deployment
66
annotations:
77
pipelinesascode.tekton.dev/max-keep-runs: "2"
88
pipelinesascode.tekton.dev/cancel-in-progress: "true"
9-
pipelinesascode.tekton.dev/on-event: "pull_request"
10-
pipelinesascode.tekton.dev/on-path-change: "[docs/***]"
11-
pipelinesascode.tekton.dev/on-target-branch: "main"
9+
pipelinesascode.tekton.dev/on-cel-expression: |
10+
event == "push" && (
11+
(target_branch == "main" && "docs/***".pathChanged()) ||
12+
target_branch.startsWith("refs/tags/")
13+
) ||
14+
(event == "pull_request" && "docs/***".pathChanged())
1215
spec:
1316
params:
1417
- name: repo_url
@@ -17,13 +20,16 @@ spec:
1720
value: "{{revision}}"
1821
- name: hugo_version
1922
value: "0.146.0"
23+
- name: wrangler_version
24+
value: "4.72.0"
2025
pipelineSpec:
2126
params:
2227
- name: repo_url
2328
- name: revision
2429
- name: hugo_version
30+
- name: wrangler_version
2531
tasks:
26-
- name: build-doc
32+
- name: deploy-doc
2733
taskSpec:
2834
workspaces:
2935
- name: source
@@ -56,16 +62,9 @@ spec:
5662
value: $(workspaces.source.path)/tmp/hugo
5763
- name: workingdir
5864
value: $(workspaces.source.path)
59-
60-
- name: hugo-gen
65+
- name: hugo-build
6166
image: docker.io/golang:1.25
6267
workingDir: $(workspaces.source.path)
63-
env:
64-
- name: UPLOADER_PUBLIC_URL
65-
valueFrom:
66-
secretKeyRef:
67-
name: "uploader-upload-credentials"
68-
key: "public_url"
6968
script: |
7069
#!/usr/bin/env bash
7170
set -xeuo pipefail
@@ -76,37 +75,56 @@ spec:
7675
echo "Hugo was not downloaded properly" && exit 1
7776
}
7877
cd $(git rev-parse --show-toplevel)/docs
79-
url="${UPLOADER_PUBLIC_URL}/docs/{{ pull_request_number }}"
80-
${hugobin} build --gc --minify -d {{ pull_request_number }} -b ${url}
81-
echo "Preview URL: ${url}"
82-
- name: upload-to-static-server
83-
# it has curl and we already pulled it
84-
image: docker.io/curlimages/curl
78+
${hugobin} build --gc --minify
79+
- name: deploy
80+
image: docker.io/node:20-slim
8581
workingDir: $(workspaces.source.path)
8682
env:
87-
- name: HUB_TOKEN
83+
- name: CLOUDFLARE_API_TOKEN
8884
valueFrom:
8985
secretKeyRef:
90-
name: "nightly-ci-github-hub-token"
91-
key: "hub-token"
92-
- name: UPLOADER_UPLOAD_CREDENTIALS
86+
name: cloudflare-creds
87+
key: api-token
88+
- name: CLOUDFLARE_ACCOUNT_ID
9389
valueFrom:
9490
secretKeyRef:
95-
name: "uploader-upload-credentials"
96-
key: "credentials"
97-
- name: UPLOADER_PUBLIC_URL
91+
name: cloudflare-creds
92+
key: account-id
93+
script: |
94+
#!/usr/bin/env bash
95+
set -euo pipefail
96+
pull_request_number="{{pull_request_number}}"
97+
git_tag="{{git_tag}}"
98+
target_branch="{{target_branch}}"
99+
100+
if [[ -n "${pull_request_number}" ]]; then
101+
branch="pr-${pull_request_number}"
102+
elif [[ -n "${git_tag}" ]]; then
103+
branch="${git_tag}"
104+
else
105+
branch="${target_branch}"
106+
fi
107+
cd docs/public
108+
npx --yes "wrangler@$(params.wrangler_version)" pages deploy . \
109+
--project-name='pipelines-as-code' \
110+
--branch="${branch}"
111+
- name: post-preview-status
112+
image: docker.io/curlimages/curl
113+
env:
114+
- name: HUB_TOKEN
98115
valueFrom:
99116
secretKeyRef:
100-
name: "uploader-upload-credentials"
101-
key: "public_url"
117+
name: "nightly-ci-github-hub-token"
118+
key: "hub-token"
102119
script: |
103-
cd docs
104-
test -d "{{ pull_request_number }}" || exit 0
105-
tar czf - "{{ pull_request_number }}" | curl -u ${UPLOADER_UPLOAD_CREDENTIALS} -F path=docs -F targz=true -X POST -F file=@- http://uploader:8080/upload
106-
# Post as status
120+
pull_request_number="{{pull_request_number}}"
121+
[[ -z "${pull_request_number}" ]] && exit 0
122+
preview_url="https://pr-${pull_request_number}.pipelines-as-code-4ko.pages.dev"
107123
set +x
108-
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 \
109-
"{\"state\": \"success\", \"target_url\": \"${UPLOADER_PUBLIC_URL}/docs/{{ pull_request_number }}\", \"description\": \"Generated with brio.\", \"context\": \"Pipelines as Code Preview URL\"}"
124+
curl -s -H "Authorization: Bearer ${HUB_TOKEN}" \
125+
-H 'Accept: application/vnd.github.v3+json' \
126+
-X POST "https://api.github.com/repos/{{repo_owner}}/{{repo_name}}/statuses/{{revision}}" \
127+
-d "{\"state\": \"success\", \"target_url\": \"${preview_url}\", \"description\": \"Documentation Preview\", \"context\": \"Pipelines as Code Preview URL\"}"
110128
- name: cache-upload
111129
ref:
112130
resolver: http
@@ -118,6 +136,8 @@ spec:
118136
value: ["$(workspaces.source.path)/README.md"]
119137
- name: target
120138
value: oci://image-registry.openshift-image-registry.svc:5000/$(context.pipelineRun.namespace)/cache-hugo:v$(params.hugo_version)
139+
- name: fetched
140+
value: $(steps.cache-fetch.results.fetched)
121141
- name: cachePath
122142
value: $(workspaces.source.path)/tmp/hugo
123143
- name: workingdir

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ Once you have the `tkn-pac` CLI installed, you can set up your first repository
372372

373373
For more detailed information, please refer to the [official documentation](https://pipelinesascode.com).
374374

375-
The documentation for the development branch is available [here](https://nightly.pipelines-as-code.pages.dev/).
375+
The documentation for the development branch is available [here](https://docs.pipelinesascode.com/nightly).
376376

377377
## Contributing
378378

docs/content/docs/dev/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ PAC targets both **arm64** and **amd64** architectures. When contributing:
190190
### Staying Updated
191191

192192
- **Releases**: Follow [GitHub releases](https://github.com/tektoncd/pipelines-as-code/releases)
193-
- **Dev docs**: Check [nightly docs](https://nightly.pipelines-as-code.pages.dev/) for latest changes
193+
- **Dev docs**: Check [nightly docs](https://docs.pipelinesascode.com/nightly) for latest changes
194194

195195
## Next Steps
196196

docs/layouts/_partials/custom/footer.html

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,12 @@
4444
function handleVersion(elm) {
4545
var path = window.location.pathname;
4646
if (elm.value === "nightly") {
47-
window.location =
48-
"https://nightly.pipelines-as-code.pages.dev" + path;
47+
window.location = "https://docs.pipelinesascode.com/nightly" + path;
4948
} else if (elm.value === "stable") {
50-
window.location = "https://pipelinesascode.com" + path;
49+
window.location = "https://docs.pipelinesascode.com/stable" + path;
5150
} else {
5251
window.location =
53-
"https://release-" +
54-
elm.value.replace(/\./g, "-") +
55-
".pipelines-as-code.pages.dev" +
56-
path;
52+
"https://docs.pipelinesascode.com/" + elm.value + path;
5753
}
5854
}
5955
</script>

0 commit comments

Comments
 (0)