Skip to content

Commit 05714df

Browse files
authored
Merge pull request #665 from Mara3l/master
ci: fix generate.sh bug
2 parents 43a9f93 + 81ddc0b commit 05714df

3 files changed

Lines changed: 41 additions & 49 deletions

File tree

.github/actions/hugo-build-action/action.yaml

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,18 @@ name: Hugo Build
22
description: Builds documentation using Hugo
33
inputs:
44
base-url:
5-
required: false
6-
description: Optional base url used during build
7-
working-directory:
8-
required: false
9-
description: Path to documentation directory
10-
default: docs
11-
hugo-env:
12-
required: false
13-
description: Environment variable
14-
default: public
15-
fetch-from:
16-
required: false
17-
description: repo to fetch the versions from
18-
default: origin
5+
required: true
6+
description: Base url used during build
197

208
runs:
219
using: "composite"
2210
steps:
23-
- uses: actions/checkout@v4
24-
- name: Setup Python
25-
uses: actions/setup-python@v5
26-
with:
27-
python-version-file: ".python-version"
28-
cache: 'pip'
29-
cache-dependency-path: scripts/script-requirements.txt
30-
- uses: actions/setup-go@v4
11+
- name: "Setup GO"
12+
uses: actions/setup-go@v4
3113
with:
3214
go-version: '>=1.20.1'
33-
- uses: actions/setup-node@v3
15+
- name: "Setup Node"
16+
uses: actions/setup-node@v3
3417
with:
3518
node-version: 18
3619
- name: "Setup Hugo"
@@ -45,4 +28,4 @@ runs:
4528
run: |
4629
cd docs
4730
npm install
48-
hugo --minify ${BASE_URL:+--baseURL $BASE_URL}
31+
hugo --minify ${BASE_URL:+--baseURL $BASE_URL} -e _default

.github/workflows/netlify-deploy-preview.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,41 +14,35 @@ jobs:
1414
netlify-deploy:
1515
runs-on: infra1-rxa-xlarge
1616
steps:
17-
- name: Checkout
17+
- name: "Checkout Recursive"
1818
uses: actions/checkout@v4
1919
with:
2020
submodules: recursive
21-
- name: Checkout
21+
- name: "Checkout to PR-tmp"
2222
uses: actions/checkout@v4
2323
with:
2424
repository: ${{ github.event.pull_request.head.repo.full_name }}
2525
ref: ${{ github.event.pull_request.head.ref }}
2626
path: 'PR-tmp'
27-
- name: Get only changed docs
27+
- name: "Get only changed docs"
2828
run: |
2929
rsync --delete -av PR-tmp/docs/content/en/ docs/content/en/
3030
rm -rf PR-tmp
31-
- name: Generate Docs
31+
- name: "Generate Docs"
3232
uses: gooddata/gooddata-python-sdk/.github/actions/hugo-build-action@master
3333
with:
3434
base-url: https://preview-${{ env.GITHUB_PR_NUMBER }}--${{ env.NETLIFY_SITE_NAME }}.netlify.app
35-
- name: Publish
35+
- name: "Publish"
3636
uses: netlify/actions/cli@master
3737
with:
3838
args: deploy -d docs/public --alias=preview-${{ env.GITHUB_PR_NUMBER }}
3939
env:
4040
NETLIFY_SITE_ID: 93e23db0-d31a-4a12-801a-b9479ffef486 # Not a secret
4141
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
42-
# `htmltest` is after publishing, so we can see the artifact.
43-
- name: htmltest
42+
# `htmltest` is after publishing, so we can see the artifact.
43+
- name: "htmltest"
4444
run: |
4545
rm -f htmltest.sh
4646
wget https://raw.githubusercontent.com/gooddata/gooddata-python-sdk/master/scripts/htmltest.sh
4747
chmod +x ./htmltest.sh
4848
./htmltest.sh -c docs/.htmltest.yml docs/public
49-
# Commented out, because it has been failing. Check up later.
50-
# - name: Comment PR
51-
# uses: thollander/actions-comment-pull-request@v2
52-
# with:
53-
# message: |
54-
# https://preview-${{ env.GITHUB_PR_NUMBER }}--${{ env.NETLIFY_SITE_NAME }}.netlify.app/

scripts/generate.sh

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ remote_name=${1:-origin}
99
# target branch where changes will be applied (master, rel/0.7, ...)
1010
target_branch=${2:-master}
1111
# Number of the versions to persist. Older ones are accesible only from GitHub.
12-
num_versions=${4:-4}
12+
num_versions=${3:-4}
1313

1414
echo "Validating target branch '$target_branch'"
1515
case "$target_branch" in
@@ -42,14 +42,15 @@ fi
4242

4343
git fetch "$remote_name"
4444

45+
4546
latest_branches=()
4647
# Get all relevant rel/* branches, sort them, and pick the latest num_versions
4748
while IFS= read -r vers; do
4849
latest_branches+=("$remote_name/rel/$vers")
4950
done < <(git branch -rl "$remote_name/rel/*" | sed 's|.*/rel/||' | sort -t. -k1,1n -k2,2n | tail -n"$num_versions")
5051

5152
# Add special branches to the array (only rel/dev and master for now)
52-
special_branches=("$remote_name/rel/dev")
53+
special_branches=("$remote_name/rel/dev" "$remote_name/master")
5354

5455
branches_to_process=("${latest_branches[@]}" "${special_branches[@]}")
5556

@@ -63,9 +64,17 @@ for branch in "${branches_to_process[@]}" ; do
6364
target_section=${branch#"$remote_name"/}
6465
target_section=${target_section#rel/}
6566
target_section=${target_section%.*}
66-
# number of path segments to throw away by tar: content/en/x.y => 3
67-
strip_count=3
68-
src_section=docs
67+
if [ "$target_section" == "master" ] ; then
68+
# handle master branch specially, all contents is copied, not just docs
69+
target_section=""
70+
# number of path segments to throw away by tar: content/en => 2
71+
strip_count=2
72+
src_section=""
73+
else
74+
# number of path segments to throw away by tar: content/en/x.y => 3
75+
strip_count=3
76+
src_section=docs
77+
fi
6978
if [ "$target_section" == "$current_section" ] ; then
7079
# copy the current docs to proper section
7180
echo "Getting data from workdir for $branch"
@@ -81,15 +90,19 @@ for branch in "${branches_to_process[@]}" ; do
8190
if git cat-file -e $API_GEN_FILE; then
8291
echo "$API_GEN_FILE exists."
8392
echo "Generating API ref..."
84-
if git ls-tree --name-only "$branch" | grep -q "^api_spec.toml$"; then
85-
git checkout "$branch" -- api_spec.toml
93+
if [ "$target_section" == "" ] ; then
94+
echo "Skipping master api ref"
8695
else
87-
echo "removing the API_spec"
88-
rm -rf api_spec.toml
96+
if git ls-tree --name-only "$branch" | grep -q "^api_spec.toml$"; then
97+
git checkout "$branch" -- api_spec.toml
98+
else
99+
echo "removing the API_spec"
100+
rm -rf api_spec.toml
101+
fi
102+
python3 ../scripts/docs/json_builder.py
103+
mv -f data.json ./versioned_docs/"$target_section"/
104+
python3 ../scripts/docs/python_ref_builder.py api_spec.toml ./versioned_docs/"$target_section"/data.json "$target_section" versioned_docs
89105
fi
90-
python3 ../scripts/docs/json_builder.py
91-
mv -f data.json ./versioned_docs/"$target_section"/
92-
python3 ../scripts/docs/python_ref_builder.py api_spec.toml ./versioned_docs/"$target_section"/data.json "$target_section" versioned_docs
93106
fi
94107
done
95108

@@ -104,4 +117,6 @@ sed "s|${highest_version}|latest|g" ./versioned_docs/latest/links.json > temp.js
104117

105118
mv temp.json ./versioned_docs/latest/links.json
106119

120+
echo "master docs will not be published, removing"
121+
rm -rf "${content_dir}/docs"
107122
popd

0 commit comments

Comments
 (0)