From 0a62f7cba905fcc9fe8aee9156f55c3af265a8aa Mon Sep 17 00:00:00 2001 From: Liam Miller-Cushon Date: Thu, 17 Dec 2020 16:35:13 -0800 Subject: [PATCH] Move doc generate from travis to GitHub actions PiperOrigin-RevId: 348115958 --- .github/workflows/ci.yml | 24 ++++++++++++++++ .travis.yml | 1 - util/generate-latest-docs.sh | 53 ++++++++++++++++-------------------- 3 files changed, 48 insertions(+), 30 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1969c1739b2..43067c4100f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,3 +84,27 @@ jobs: CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} run: mvn source:jar deploy -B -DskipTests=true -Dinvoker.skip=true -Dmaven.javadoc.skip=true + + generate_docs: + name: 'Generate latest docs' + needs: test + if: github.event_name == 'push' && github.repository == 'google/error-prone' && github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - name: 'Check out repository' + uses: actions/checkout@v2 + - name: 'Cache local Maven repository' + uses: actions/cache@v2 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + - name: 'Set up JDK 11' + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: 'Generate latest docs' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./util/generate-latest-docs.sh diff --git a/.travis.yml b/.travis.yml index 9776cef234c..5093cc171e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,7 +59,6 @@ env: after_success: - util/publish-snapshot-on-commit.sh - - util/generate-latest-docs.sh # https://docs.travis-ci.com/user/web-ui/#build-pushed-branches # safelist diff --git a/util/generate-latest-docs.sh b/util/generate-latest-docs.sh index 237c1fd4bec..48258dc6553 100755 --- a/util/generate-latest-docs.sh +++ b/util/generate-latest-docs.sh @@ -16,38 +16,33 @@ set -eu -if [ "$TRAVIS_REPO_SLUG" == "google/error-prone" ] && \ - [ "$TRAVIS_JDK_VERSION" == "openjdk15" ] && \ - [ "$TRAVIS_PULL_REQUEST" == "false" ] && \ - [ "$TRAVIS_BRANCH" == "master" ]; then - echo -e "Publishing docs...\n" +echo -e "Publishing docs...\n" - GH_PAGES_DIR=$HOME/gh-pages +GH_PAGES_DIR=$HOME/gh-pages - git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/google/error-prone $GH_PAGES_DIR > /dev/null - ( - cd $GH_PAGES_DIR - rm -rf _data/bugpatterns.yaml api/latest - mkdir -p _data api/latest - ) +git clone --quiet --branch=gh-pages https://${GH_TOKEN}@github.com/google/error-prone $GH_PAGES_DIR > /dev/null +( + cd $GH_PAGES_DIR + rm -rf _data/bugpatterns.yaml api/latest + mkdir -p _data api/latest +) - mvn -P '!examples' javadoc:aggregate - rsync -a target/site/apidocs/ ${GH_PAGES_DIR}/api/latest +mvn -P '!examples' javadoc:aggregate +rsync -a target/site/apidocs/ ${GH_PAGES_DIR}/api/latest - # The "mvn clean" is necessary since the wiki docs are generated by an - # annotation processor that also compiles the code. If Maven thinks the code - # does not need to be recompiled, the wiki docs will not be generated either. - mvn clean +# The "mvn clean" is necessary since the wiki docs are generated by an +# annotation processor that also compiles the code. If Maven thinks the code +# does not need to be recompiled, the wiki docs will not be generated either. +mvn clean - mvn -P run-annotation-processor compile site - rsync -a docgen/target/generated-wiki/ ${GH_PAGES_DIR} +mvn -P run-annotation-processor compile site +rsync -a docgen/target/generated-wiki/ ${GH_PAGES_DIR} - cd $GH_PAGES_DIR - git add --all . - git config --global user.name "travis-ci" - git config --global user.email "travis@travis-ci.org" - git commit -m "Latest docs on successful travis build $TRAVIS_BUILD_NUMBER auto-pushed to gh-pages" - git push -fq origin gh-pages > /dev/null - - echo -e "Published docs to gh-pages.\n" -fi +cd $GH_PAGES_DIR +git add --all . +git config --global user.name "travis-ci" +git config --global user.email "travis@travis-ci.org" +git commit -m "Latest docs on successful travis build $TRAVIS_BUILD_NUMBER auto-pushed to gh-pages" +git push -fq origin gh-pages > /dev/null + +echo -e "Published docs to gh-pages.\n"