From f065d361b1c1b2da91d64b6e4c07cf4fc313dc53 Mon Sep 17 00:00:00 2001 From: Topher Lubaway Date: Tue, 19 Apr 2022 14:49:04 -0500 Subject: [PATCH] Toph docs pipeline fixes bugs n gitbook (#12114) * WIP * WIP2 * WIP3 * Remove comment/better comments * Remote deployment updates * Adds GH user for yarn deploy * WIP 6 * WIP7 * WIP8 * WIP 10 * Working easy from home not so much in the cloud --- .github/workflows/documentation.yml | 7 ++-- tools/bin/check_docusaurus_build_changes | 4 +- tools/bin/deploy_docusaurus | 53 +++++++++++++++++------- 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index 7dec4e5e919c..793172b2911a 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -2,14 +2,14 @@ name: compile-docusaurus-static-assets on: push: - branches: [master, toph_an_endless_persuit_of_docs] + branches: [master] # Allows you to run this workflow manually from the Actions tab workflow_dispatch: # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - verify-docusaurus-static-files: + deploy-docusaurus-to-docs-airbyte-io: runs-on: ubuntu-latest steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it @@ -26,9 +26,8 @@ jobs: node-version: '16.13.0' cache: 'yarn' cache-dependency-path: docusaurus - # disabled for green build. more testing needed # # Build Docusaurus website - # - name: Check for docusaurus changes + # - name: Check for docusaurus changes not committed # run: ./tools/bin/check_docusaurus_build_changes # # Install and build Docusaurus website # - name: Deploy docs to production (it's weird) diff --git a/tools/bin/check_docusaurus_build_changes b/tools/bin/check_docusaurus_build_changes index 22f5b6f0d0b6..457c709e0d4b 100755 --- a/tools/bin/check_docusaurus_build_changes +++ b/tools/bin/check_docusaurus_build_changes @@ -43,8 +43,8 @@ set -o errexit set +o xtrace if test $clean -eq 0; then - echo -e "$red_text""\n\n\nDocusaurs has no changes to commit!""$default_text" - echo -e "$red_text""Generated documentation should be as local testing""$default_text" + echo -e "$blue_text""\n\n\nDocusaurs has no changes to commit!""$default_text" + echo -e "$blue_text""Generated documentation should be as local testing""$default_text" else echo -e "$red_text""\n\n\ndocusaurs build resulted in changes from this commit.""$default_text" diff --git a/tools/bin/deploy_docusaurus b/tools/bin/deploy_docusaurus index 3d96bc791bcb..2f74f66cac9c 100755 --- a/tools/bin/deploy_docusaurus +++ b/tools/bin/deploy_docusaurus @@ -31,6 +31,7 @@ pwd # Yarn check (which is commonly used to check for program existance) +# -s/--silent doesn't exist in cloud's Ubuntu if ! which yarn > /dev/null; then echo -e "$red_text""yarn not found HALP!!\n\n""$default_text" exit 1 @@ -38,16 +39,12 @@ fi set -o xtrace -# touch is non-destructive and the cloud doesn't have this file -touch $HOME/.gitconfig - -# Set email and user name -if ! git config --list --global | grep --silent user.email; then +# local check for changes. Fail here early instead of 40 seconds from now +if ! test -z "$(git status --short)"; then set +o xtrace - echo -e "$blue_text""github email not found adding Octavia's""$default_text" - set -o xtrace - git config --global user.email="octavia-squidington-iii@users.noreply.github.com" - git config --global user.name="octavia-squidington-iii" + echo -e "$red_text""You have uncommitted changes!!!\n\n""$default_text" + echo -e "$red_text""Commit and try again""$default_text" + exit 1 fi cd docusaurus @@ -59,9 +56,23 @@ yarn install # generate static content yarn build -# context https://v1.docusaurus.io/docs/en/publishing#using-github-pages -# write a prod website to airbytehq/airbyte gh_pages branch -GIT_USER=octavia-squidington-iii yarn run deploy +# Check tty for local/remote deploys (we expect cloud to be non-interactive) +# results like /dev/ttys000 || not a tty +if test "$(tty)" == "not a tty"; then + set +o xtrace + echo -e "$blue_text""github email not found adding Octavia's""$default_text" + set -o xtrace + git config user.email="octavia-squidington-iii@users.noreply.github.com" + git config user.name="octavia-squidington-iii" + echo "machine github.com login octavia-squidington-iii password $GITHUB_TOKEN" > $HOME/.netrc + # context https://v1.docusaurus.io/docs/en/publishing#using-github-pages + # write a prod website to airbytehq/airbyte gh_pages branch + # NOT ACTUALLY WORKING + GIT_USER="octavia-squidington-iii" yarn run publish-gh-pages +else + yarn run deploy +fi + @@ -71,8 +82,11 @@ pwd # We should be here but we are playing with fire git fetch +# We force push gh-pages. Local copies confuse things +# This line uses || true to enure we don't error if that branch doesn't exist +git branch -D gh-pages 2> /dev/null || true # checkout the branch tracking it's remote -git switch gh-pages +git switch --track origin/gh-pages # For tracking in the commit message revision=$(git rev-parse --short HEAD) @@ -94,11 +108,18 @@ git commit --message "Adds CNAME to deploy for $revision" # non functional. for debugging git branch -# note that this is NOT airbyte repo -git push --force https://$GITHUB_TOKEN@github.com/airbytehq/airbytehq.github.io.git +if test "$(tty)" == "not a tty"; then + # note that this is NOT airbyte repo + git push --force https://octavia-squidington-iii:$GITHUB_TOKEN@github.com/airbytehq/airbytehq.github.io.git +else + git push --force git@github.com:airbytehq/airbytehq.github.io.git +fi + +# Let's leave the tire fire of force pushes +git checkout - + # Want to push from your own computer? uncomment this line and comment out the push above -# git push --force https://git@github.com/airbytehq/airbytehq.github.io.git set +o xtrace echo -e "$blue_text""Script exiting 0 GREAT SUCCESS!!!?""$default_text"