From 171a063590609ddf2f57260c324a6eb62c244b5f Mon Sep 17 00:00:00 2001 From: Christopher Fenner <26137398+CCFenner@users.noreply.github.com> Date: Fri, 17 Apr 2020 17:44:31 +0200 Subject: [PATCH] chore: add gh-action to generate docs (#1386) * add workflow to generate docs * Update documentation.yaml * Update createDocu.sh * add caching * fix c&p error * Update documentation.yaml * Update documentation.yaml * remove docs build from travis * activate workflow for PRs --- .github/workflows/documentation.yaml | 78 ++++++++++++++++++++++++++++ .travis.yml | 21 -------- documentation/bin/createDocu.sh | 2 +- 3 files changed, 79 insertions(+), 22 deletions(-) create mode 100644 .github/workflows/documentation.yaml diff --git a/.github/workflows/documentation.yaml b/.github/workflows/documentation.yaml new file mode 100644 index 000000000..3595bc22d --- /dev/null +++ b/.github/workflows/documentation.yaml @@ -0,0 +1,78 @@ +name: Documentation + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + github-pages: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@v2 + + - uses: actions/setup-java@v1 + with: + java-version: '1.8' + + - uses: actions/setup-go@v1 + with: + go-version: '1.13.x' + + - name: Install Groovy + run: sudo apt-get update && sudo apt-get install groovy -y + + - name: Cache Maven Packages + uses: actions/cache@v1 + with: + path: ~/.m2/repository + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} + restore-keys: | + ${{ runner.os }}-maven- + + - name: Cache Go Packages + uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - run: docker pull ppiper/jenkinsfile-runner:latest + + - name: Generate Groovy Docs + env: + MAVEN_OPTS: -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + run: documentation/bin/createDocu.sh + + - name: Generate Golang Docs + run: go run pkg/generator/step-metadata.go --docuDir=documentation/docs/steps/ --docuGen=true + + - run: docker pull squidfunk/mkdocs-material:3.0.4 + + - name: Build + run: | + docker run \ + -u $(id -u):$(id -g) \ + -v ${GITHUB_WORKSPACE}/documentation:/docs \ + squidfunk/mkdocs-material:3.0.4 build --clean --strict + + - name: Provide Docs Metadata + run: | + mkdir -p documentation/docs-gen/misc + cp target/docuMetaData.json documentation/docs-gen/misc + + - name: Deploy + if: github.ref == 'refs/heads/master' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./documentation/docs-gen + user_name: 'github-actions[bot]' + user_email: '41898282+github-actions[bot]@users.noreply.github.com' + keep_files: true + force_orphan: true diff --git a/.travis.yml b/.travis.yml index 81f54e547..b0547ec68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,24 +25,3 @@ jobs: name: Consumer Tests if: repo = "SAP/jenkins-library" && ( (type != pull_request && branch =~ /^master$|^it\/.*$/) || (type == pull_request && head_repo = "SAP/jenkins-library" && head_branch =~ /^it\/.*$/) ) script: cd consumer-test && groovy consumerTestController.groovy - - stage: Docs - name: Create Documentation - install: docker pull squidfunk/mkdocs-material:3.0.4 - before_script: - - documentation/bin/createDocu.sh - - docker run -u `id -u`:`id -g` --rm -it -e GOCACHE=/tmp -v ${TRAVIS_BUILD_DIR}:/docu-gen golang sh -c "cd /docu-gen && go get github.com/SAP/jenkins-library/... && go run /docu-gen/pkg/generator/step-metadata.go --docuDir=/docu-gen/documentation/docs/steps/ --docuGen=true " - script: - - docker run -u `id -u`:`id -g` --rm -it -v ${TRAVIS_BUILD_DIR}/documentation:/docs squidfunk/mkdocs-material:3.0.4 build --clean --strict - after_script: - - mkdir -p documentation/docs-gen/misc - - cp target/docuMetaData.json documentation/docs-gen/misc - deploy: - on: - branch: master - provider: pages - skip_cleanup: true - github_token: ${GITHUB_TOKEN} - name: 'Travis CI Publisher' - local_dir: 'documentation/docs-gen' - keep_history: true - #verbose: true diff --git a/documentation/bin/createDocu.sh b/documentation/bin/createDocu.sh index 43793f34c..1b529fd32 100755 --- a/documentation/bin/createDocu.sh +++ b/documentation/bin/createDocu.sh @@ -18,7 +18,7 @@ do done export CLASSPATH_FILE='target/cp.txt' -mvn clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} +mvn --batch-mode --show-version clean test dependency:build-classpath -Dmdep.outputFile=${CLASSPATH_FILE} if [ "$?" != "0" ];then echo "[ERROR] maven test / build-classpath failed"