Fix/maintainability issues #49
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Update documentation" | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| tags: | |
| - v* | |
| branches: [ "master" ] | |
| paths: | |
| - docs/** | |
| - hack/doc-site/** | |
| - .github/workflows/update-doc.yml | |
| pull_request: | |
| paths: | |
| - docs/** | |
| - hack/doc-site/** | |
| - .github/workflows/update-doc.yml | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| defaults: | |
| run: | |
| shell: bash | |
| jobs: | |
| build-doc: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - | |
| name: Checkout | |
| uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 | |
| with: | |
| fetch-depth: '1' | |
| submodules: recursive | |
| sparse-checkout: | | |
| hack/ | |
| docs/ | |
| - | |
| name: Get all tags [go-openapi repo] | |
| if: ${{ github.repository == 'go-openapi/testify' }} | |
| run: | | |
| git fetch origin --prune --update-shallow --tags 'refs/tags/*:refs/tags/*' | |
| - | |
| name: Get all tags [fork] | |
| if: ${{ github.repository != 'go-openapi/testify' }} | |
| run: | | |
| git remote add upstream "https://github.com/go-openapi/testify" | |
| git fetch upstream --prune --update-shallow --tags 'refs/tags/*:refs/tags/*' | |
| git fetch origin --prune --update-shallow --tags 'refs/tags/*:refs/tags/*' | |
| - | |
| name: Initialize theme | |
| env: | |
| RELEARN_VERSION: 9.0.3 | |
| run: | | |
| cd hack/doc-site/hugo | |
| # Clone theme | |
| curl -sL -o relearn.tgz https://github.com/McShelby/hugo-theme-relearn/archive/refs/tags/"${RELEARN_VERSION}".tar.gz | |
| tar xf relearn.tgz | |
| rm -rf themes/hugo-relearn | |
| mv "hugo-theme-relearn-${RELEARN_VERSION}" hugo-relearn | |
| mv hugo-relearn themes/ | |
| - | |
| name: Prepare config | |
| run: | | |
| # Builds a commit-dependant extra config to inject parameterization. | |
| # HUGO doesn't support config from the command line. | |
| # | |
| # Set specific parameters that are used in some parameterized document. | |
| # This is used to keep up-to-date installation instructions. | |
| cd hack/doc-site/hugo | |
| ROOT=$(git rev-parse --show-toplevel) | |
| VERSION_MESSAGE="Documentation set for latest master." | |
| REQUIRED_GO_VERSION=$(grep "^go\s" "${ROOT}"/go.mod|cut -d" " -f2) | |
| LATEST_RELEASE=$(git tag --list --sort -version:refname 'v*' 2>/dev/null | head -1 || echo "dev") | |
| BUILD_TIME=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | |
| echo " Latest release: ${LATEST_RELEASE}" | |
| echo " Go version: ${REQUIRED_GO_VERSION}" | |
| echo " Build time: ${BUILD_TIME}" | |
| echo " Version message: ${VERSION_MESSAGE}" | |
| # Generate dynamic config | |
| cat testify.yaml.template \ | |
| | sed "s|{{ GO_VERSION }}|${REQUIRED_GO_VERSION}|g" \ | |
| | sed "s|{{ LATEST_RELEASE }}|${LATEST_RELEASE}|g" \ | |
| | sed "s|{{ VERSION_MESSAGE }}|${VERSION_MESSAGE}|g" \ | |
| | sed "s|{{ BUILD_TIME }}|${BUILD_TIME}|g" \ | |
| > testify.yaml | |
| - | |
| name: Build site with Hugo | |
| uses: crazy-max/ghaction-hugo@58bd8ea36dbac3f6155d275a04e0b55604a93c48 # v3.2.0 | |
| with: | |
| version: v0.153.3 # <- pin the HUGO version, as they often break things | |
| extended: true | |
| args: > | |
| --config hugo.yaml,testify.yaml | |
| --buildDrafts | |
| --cleanDestinationDir | |
| --minify | |
| --printPathWarnings | |
| --ignoreCache | |
| --noBuildLock | |
| --logLevel info | |
| --source ${{ github.workspace }}/hack/doc-site/hugo" | |
| - | |
| name: Upload artifact | |
| uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0 | |
| with: | |
| path: hack/doc-site/hugo/public | |
| deploy-doc: | |
| if: ${{ github.event_name != 'pull_request' }} | |
| needs: build-doc | |
| outputs: | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pages: write | |
| id-token: write | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - | |
| name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 | |
| - | |
| name: Report URL | |
| run: | | |
| echo "::notice::Deployed doc site to ${{ steps.deployment.outputs.page_url }}" |