From 8ad8ed17124197e9adb5d2444227ea0b472b8084 Mon Sep 17 00:00:00 2001 From: Brad Corso Date: Wed, 24 Nov 2021 15:21:31 -0800 Subject: [PATCH] Fix issue with Dagger release workflow publishing tagged docs. This CL sets up the publish-tagged-docs script to use the access token, GH_TOKEN, if one exists, to avoid having to setup ssh and manually authenticate. RELNOTES=N/A PiperOrigin-RevId: 412144152 --- .github/workflows/release.yml | 2 ++ util/publish-tagged-docs.sh | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index feb322fd33e..317aa9f333b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -253,6 +253,8 @@ jobs: - name: 'Publish tagged docs' run: util/publish-tagged-docs.sh ${{ env.DAGGER_RELEASE_VERSION }} shell: bash + env: + GH_TOKEN: ${{ github.token }} - name: 'Clean bazel cache' # According to the documentation, we should be able to exclude these via # the actions/cache path, e.g. "!~/.cache/bazel/*/*/external/" but that diff --git a/util/publish-tagged-docs.sh b/util/publish-tagged-docs.sh index 6c08a182df9..df012867dd8 100755 --- a/util/publish-tagged-docs.sh +++ b/util/publish-tagged-docs.sh @@ -1,4 +1,5 @@ #!/bin/bash +# TODO(bcorso): Consider sharing this script with utils/generate-latest-docs.sh set -eux @@ -21,8 +22,15 @@ fi # Publish javadocs to gh-pages bazel build //:user-docs.jar -git clone --quiet --branch gh-pages \ - https://github.com/google/dagger gh-pages > /dev/null + +# If a token exists, then use the token to clone the repo. This allows our +# automated workflows to commit without manually authenticating. +if [[ ! -z "$GH_TOKEN" ]]; then + git clone --quiet --branch=gh-pages https://x-access-token:${GH_TOKEN}@github.com/google/dagger gh-pages > /dev/null +else + git clone --quiet --branch=gh-pages https://github.com/google/dagger gh-pages > /dev/null +fi + cd gh-pages unzip ../bazel-bin/user-docs.jar -d api/$VERSION_NAME rm -rf api/$VERSION_NAME/META-INF/