diff --git a/.github/actions/hugo-build-action/action.yaml b/.github/actions/hugo-build-action/action.yaml index 0de15a5c9..fd287fe46 100644 --- a/.github/actions/hugo-build-action/action.yaml +++ b/.github/actions/hugo-build-action/action.yaml @@ -2,35 +2,18 @@ name: Hugo Build description: Builds documentation using Hugo inputs: base-url: - required: false - description: Optional base url used during build - working-directory: - required: false - description: Path to documentation directory - default: docs - hugo-env: - required: false - description: Environment variable - default: public - fetch-from: - required: false - description: repo to fetch the versions from - default: origin + required: true + description: Base url used during build runs: using: "composite" steps: - - uses: actions/checkout@v4 - - name: Setup Python - uses: actions/setup-python@v5 - with: - python-version-file: ".python-version" - cache: 'pip' - cache-dependency-path: scripts/script-requirements.txt - - uses: actions/setup-go@v4 + - name: "Setup GO" + uses: actions/setup-go@v4 with: go-version: '>=1.20.1' - - uses: actions/setup-node@v3 + - name: "Setup Node" + uses: actions/setup-node@v3 with: node-version: 18 - name: "Setup Hugo" @@ -45,4 +28,4 @@ runs: run: | cd docs npm install - hugo --minify ${BASE_URL:+--baseURL $BASE_URL} + hugo --minify ${BASE_URL:+--baseURL $BASE_URL} -e _default diff --git a/.github/workflows/netlify-deploy-preview.yaml b/.github/workflows/netlify-deploy-preview.yaml index a0c2a3ee0..4db218f22 100644 --- a/.github/workflows/netlify-deploy-preview.yaml +++ b/.github/workflows/netlify-deploy-preview.yaml @@ -14,41 +14,35 @@ jobs: netlify-deploy: runs-on: infra1-rxa-xlarge steps: - - name: Checkout + - name: "Checkout Recursive" uses: actions/checkout@v4 with: submodules: recursive - - name: Checkout + - name: "Checkout to PR-tmp" uses: actions/checkout@v4 with: repository: ${{ github.event.pull_request.head.repo.full_name }} ref: ${{ github.event.pull_request.head.ref }} path: 'PR-tmp' - - name: Get only changed docs + - name: "Get only changed docs" run: | rsync --delete -av PR-tmp/docs/content/en/ docs/content/en/ rm -rf PR-tmp - - name: Generate Docs + - name: "Generate Docs" uses: gooddata/gooddata-python-sdk/.github/actions/hugo-build-action@master with: base-url: https://preview-${{ env.GITHUB_PR_NUMBER }}--${{ env.NETLIFY_SITE_NAME }}.netlify.app - - name: Publish + - name: "Publish" uses: netlify/actions/cli@master with: args: deploy -d docs/public --alias=preview-${{ env.GITHUB_PR_NUMBER }} env: NETLIFY_SITE_ID: 93e23db0-d31a-4a12-801a-b9479ffef486 # Not a secret NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} -# `htmltest` is after publishing, so we can see the artifact. - - name: htmltest + # `htmltest` is after publishing, so we can see the artifact. + - name: "htmltest" run: | rm -f htmltest.sh wget https://raw.githubusercontent.com/gooddata/gooddata-python-sdk/master/scripts/htmltest.sh chmod +x ./htmltest.sh ./htmltest.sh -c docs/.htmltest.yml docs/public -# Commented out, because it has been failing. Check up later. -# - name: Comment PR -# uses: thollander/actions-comment-pull-request@v2 -# with: -# message: | -# https://preview-${{ env.GITHUB_PR_NUMBER }}--${{ env.NETLIFY_SITE_NAME }}.netlify.app/ diff --git a/scripts/generate.sh b/scripts/generate.sh index f4f8079d9..82e377d43 100755 --- a/scripts/generate.sh +++ b/scripts/generate.sh @@ -9,7 +9,7 @@ remote_name=${1:-origin} # target branch where changes will be applied (master, rel/0.7, ...) target_branch=${2:-master} # Number of the versions to persist. Older ones are accesible only from GitHub. -num_versions=${4:-4} +num_versions=${3:-4} echo "Validating target branch '$target_branch'" case "$target_branch" in @@ -42,6 +42,7 @@ fi git fetch "$remote_name" + latest_branches=() # Get all relevant rel/* branches, sort them, and pick the latest num_versions while IFS= read -r vers; do @@ -49,7 +50,7 @@ while IFS= read -r vers; do done < <(git branch -rl "$remote_name/rel/*" | sed 's|.*/rel/||' | sort -t. -k1,1n -k2,2n | tail -n"$num_versions") # Add special branches to the array (only rel/dev and master for now) -special_branches=("$remote_name/rel/dev") +special_branches=("$remote_name/rel/dev" "$remote_name/master") branches_to_process=("${latest_branches[@]}" "${special_branches[@]}") @@ -63,9 +64,17 @@ for branch in "${branches_to_process[@]}" ; do target_section=${branch#"$remote_name"/} target_section=${target_section#rel/} target_section=${target_section%.*} - # number of path segments to throw away by tar: content/en/x.y => 3 - strip_count=3 - src_section=docs + if [ "$target_section" == "master" ] ; then + # handle master branch specially, all contents is copied, not just docs + target_section="" + # number of path segments to throw away by tar: content/en => 2 + strip_count=2 + src_section="" + else + # number of path segments to throw away by tar: content/en/x.y => 3 + strip_count=3 + src_section=docs + fi if [ "$target_section" == "$current_section" ] ; then # copy the current docs to proper section echo "Getting data from workdir for $branch" @@ -81,15 +90,19 @@ for branch in "${branches_to_process[@]}" ; do if git cat-file -e $API_GEN_FILE; then echo "$API_GEN_FILE exists." echo "Generating API ref..." - if git ls-tree --name-only "$branch" | grep -q "^api_spec.toml$"; then - git checkout "$branch" -- api_spec.toml + if [ "$target_section" == "" ] ; then + echo "Skipping master api ref" else - echo "removing the API_spec" - rm -rf api_spec.toml + if git ls-tree --name-only "$branch" | grep -q "^api_spec.toml$"; then + git checkout "$branch" -- api_spec.toml + else + echo "removing the API_spec" + rm -rf api_spec.toml + fi + python3 ../scripts/docs/json_builder.py + mv -f data.json ./versioned_docs/"$target_section"/ + python3 ../scripts/docs/python_ref_builder.py api_spec.toml ./versioned_docs/"$target_section"/data.json "$target_section" versioned_docs fi - python3 ../scripts/docs/json_builder.py - mv -f data.json ./versioned_docs/"$target_section"/ - python3 ../scripts/docs/python_ref_builder.py api_spec.toml ./versioned_docs/"$target_section"/data.json "$target_section" versioned_docs fi done @@ -104,4 +117,6 @@ sed "s|${highest_version}|latest|g" ./versioned_docs/latest/links.json > temp.js mv temp.json ./versioned_docs/latest/links.json +echo "master docs will not be published, removing" +rm -rf "${content_dir}/docs" popd