From 26239935b3eae491fcceae45c89cd0436e0b59f3 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Wed, 7 Jul 2021 11:34:53 -0400 Subject: [PATCH] ceph-website: Split job into two (PRs and main) The PRs job will build PRs. The non-PRs job will build the production website. Signed-off-by: David Galloway --- ceph-website-prs/build/build | 25 ++++++++ .../config/definitions/ceph-website-prs.yml | 58 +++++++++++++++++++ ceph-website/build/build | 21 ++----- .../config/definitions/ceph-website.yml | 28 +-------- 4 files changed, 88 insertions(+), 44 deletions(-) create mode 100755 ceph-website-prs/build/build create mode 100644 ceph-website-prs/config/definitions/ceph-website-prs.yml diff --git a/ceph-website-prs/build/build b/ceph-website-prs/build/build new file mode 100755 index 00000000..08b0d444 --- /dev/null +++ b/ceph-website-prs/build/build @@ -0,0 +1,25 @@ +#!/bin/bash +set -ex + +## TODO: Check if only the src/ dir changed and `exit 0` if only the ceph.io.git README or something else inconsequential changed. +env + +BRANCH=$(echo $GIT_BRANCH | sed 's:.*/::') + +# https://docs.npmjs.com/cli/v7/commands/npm-ci +npm ci + +npm run build:development + +if [ ! -d /opt/www/${BRANCH} ]; then + mkdir -p /opt/www/${BRANCH} +fi + +rsync -av --delete-after dist/ /opt/www/${BRANCH}/ + +# This just makes the last `echo` line not repeat +{ set +x; } 2>/dev/null + +echo "Success! This site is available at https://${BRANCH}.ceph.io." + +## TODO: Prune deleted branches from /opt/www/ diff --git a/ceph-website-prs/config/definitions/ceph-website-prs.yml b/ceph-website-prs/config/definitions/ceph-website-prs.yml new file mode 100644 index 00000000..4efa717b --- /dev/null +++ b/ceph-website-prs/config/definitions/ceph-website-prs.yml @@ -0,0 +1,58 @@ +- job: + name: ceph-website-prs + description: This job builds PRs from github.com/ceph/ceph.io and serves them at $branch.ceph.io. + node: www + project-type: freestyle + defaults: global + quiet-period: 5 + block-downstream: false + block-upstream: false + properties: + - build-discarder: + days-to-keep: 1 + num-to-keep: 10 + artifact-days-to-keep: -1 + artifact-num-to-keep: -1 + - github: + url: https://github.com/ceph/ceph.io + + parameters: + - string: + name: sha1 + description: "A pull request ID or branch, like 'origin/pr/72/head' or wip-blogpost1" + + triggers: + - github-pull-request: + org-list: + - ceph + white-list: + - adamduncan + - Pete-Robelou + cancel-builds-on-update: true + trigger-phrase: 'jenkins test.*|jenkins retest.*' + only-trigger-phrase: false + github-hooks: true + permit-all: false + auto-close-on-fail: false + status-context: "Compiling site" + started-status: "Compiling site" + success-status: "Site compiled successfully!" + failure-status: "Site compilation failed" +# This is kinda noisy if there's lots of force pushes +# success-comment: "Site built successfully! https://${GIT_BRANCH}.ceph.io" + + scm: + - git: + url: https://github.com/ceph/ceph.io + branches: + - origin/pr/${ghprbPullId}/merge + refspec: +refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/* + browser: auto + skip-tag: true + timeout: 20 + wipe-workspace: true + + builders: + - shell: + !include-raw: + - ../../build/build diff --git a/ceph-website/build/build b/ceph-website/build/build index e8a8a8b3..3b8cc53e 100755 --- a/ceph-website/build/build +++ b/ceph-website/build/build @@ -4,25 +4,12 @@ set -ex ## TODO: Check if only the src/ dir changed and `exit 0` if only the ceph.io.git README or something else inconsequential changed. env -BRANCH=$(echo $GIT_BRANCH | sed 's:.*/::') - npm install -if [ "$BRANCH" == "main" ]; then - npm run build:production -else - npm run build:development -fi +npm run build:production -if [ ! -d /opt/www/${BRANCH} ]; then - mkdir -p /opt/www/${BRANCH} +if [ ! -d /opt/www/main ]; then + mkdir -p /opt/www/main fi -rsync -av --delete-after dist/ /opt/www/${BRANCH}/ - -# This just makes the last `echo` line not repeat -{ set +x; } 2>/dev/null - -echo "Success! This site is available at https://${BRANCH}.ceph.io." - -## TODO: Prune deleted branches from /opt/www/ +rsync -av --delete-after dist/ /opt/www/main/ diff --git a/ceph-website/config/definitions/ceph-website.yml b/ceph-website/config/definitions/ceph-website.yml index 89d134de..24e2c2ef 100644 --- a/ceph-website/config/definitions/ceph-website.yml +++ b/ceph-website/config/definitions/ceph-website.yml @@ -1,6 +1,6 @@ - job: name: ceph-website - description: This job builds branches from github.com/ceph/ceph.io and updates the website accordingly. + description: This job builds the main branch of https://github.com/ceph/ceph.io and keeps the website up to date node: www project-type: freestyle defaults: global @@ -16,39 +16,14 @@ - github: url: https://github.com/ceph/ceph.io - parameters: - - string: - name: sha1 - description: "A pull request ID or branch, like 'origin/pr/72/head' or wip-blogpost1" - triggers: - github - - github-pull-request: - org-list: - - ceph - white-list: - - adamduncan - - Pete-Robelou - cancel-builds-on-update: true - trigger-phrase: 'jenkins test.*|jenkins retest.*' - only-trigger-phrase: false - github-hooks: true - permit-all: false - auto-close-on-fail: false - status-context: "Compiling site" - started-status: "Compiling site" - success-status: "Site compiled successfully!" - failure-status: "Site compilation failed" -# This is kinda noisy if there's lots of force pushes -# success-comment: "Site built successfully! https://${GIT_BRANCH}.ceph.io" scm: - git: url: https://github.com/ceph/ceph.io branches: - main - - origin/pr/${ghprbPullId}/merge - refspec: +refs/pull/${ghprbPullId}/*:refs/remotes/origin/pr/${ghprbPullId}/* browser: auto skip-tag: true timeout: 20 @@ -57,5 +32,4 @@ builders: - shell: !include-raw: - - ../../../scripts/build_utils.sh - ../../build/build -- 2.39.5