diff --git a/.github/workflows/trybot.yaml b/.github/workflows/trybot.yaml index ae4241482..266723277 100644 --- a/.github/workflows/trybot.yaml +++ b/.github/workflows/trybot.yaml @@ -241,3 +241,6 @@ jobs: - if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test')) name: 'tip.cuelang.org: Check if the site builds against the tip of cue-lang/cue' run: _scripts/regenPostInfraChange.bash + - if: github.repository == 'cue-lang/cuelang.org' && (github.ref == 'refs/heads/master' || (github.ref == 'refs/heads/ci/test')) + name: 'tip.cuelang.org: Deploy the site' + run: _scripts/tipDeploy.bash diff --git a/_scripts/tipDeploy.bash b/_scripts/tipDeploy.bash new file mode 100755 index 000000000..cc1173266 --- /dev/null +++ b/_scripts/tipDeploy.bash @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Usage: +# tipDeploy.bash +# +# tipDeploy commits the current state of the working tree and force-pushes it +# to the "tip" branch, which triggers a build-and-deploy of tip.cuelang.org +# inside Netlify. + +# cd to the parent directory to that containing the script +cd "$( dirname "${BASH_SOURCE[0]}" )" +cd .. + +headShortRef=$(git rev-parse --short HEAD) + +git add content/**/gen_cache.cue +git commit --allow-empty --message "tip.cuelang.org: $headShortRef: cache files" +git add . +git commit --allow-empty --message "tip.cuelang.org: $headShortRef: source changes" + +# A --force push is required because there's no automated *and meaningful* path +# between the current state of the tip branch and the state we wish to push. +# We don't lose any information by force pushing to this branch, whose only +# purpose is to communicate the state that needs to be deployed and to act as a +# trigger for the build inside Netlify. +git push --force origin HEAD:tip diff --git a/internal/ci/github/trybot.cue b/internal/ci/github/trybot.cue index 7397b5d8a..e62296427 100644 --- a/internal/ci/github/trybot.cue +++ b/internal/ci/github/trybot.cue @@ -271,6 +271,12 @@ workflows: trybot: _repo.bashWorkflow & { if: "github.repository == '\(_repo.githubRepositoryPath)' && (github.ref == 'refs/heads/\(_repo.defaultBranch)' || \(_repo.isTestDefaultBranch))" run: "_scripts/regenPostInfraChange.bash" }, + json.#step & { + name: "tip.cuelang.org: Deploy the site" + // Only run in the main repo on the default branch or its designated test branch. + if: "github.repository == '\(_repo.githubRepositoryPath)' && (github.ref == 'refs/heads/\(_repo.defaultBranch)' || \(_repo.isTestDefaultBranch))" + run: "_scripts/tipDeploy.bash" + }, ] }