Skip to content

Commit e0ea223

Browse files
committed
Fix publish docs for branches
There was a bug in the tests for GitHub environment variables that led to the documentation build system using an undefined environment variable which resulted in an empty branch name. Determining the correct branch or tag name from within cmake using GitHub environment variables is unreliable, so instead the correct name is determined by the workflows, which set an environment variable that can be used by cmake. Signed-off-by: Winford <winford@object.stream>
1 parent a239060 commit e0ea223

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

.github/workflows/build-docs.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,15 @@ jobs:
7777
python3 -m pip install breathe
7878
python3 -m pip install pygments
7979
80+
- name: Set docs target name
81+
shell: bash
82+
run: |
83+
if [[ ${{ github.ref_name }} == *"/merge" ]]; then
84+
echo "AVM_DOCS_NAME=${{github.event.pull_request.base.ref}}" >> "$GITHUB_ENV";
85+
else
86+
echo "AVM_DOCS_NAME=${{ github.ref_name }}" >> "$GITHUB_ENV";
87+
fi
88+
8089
- uses: actions/checkout@v4
8190
with:
8291
repository: ${{ vars.GITHUB_REPOSITORY }}

.github/workflows/publish-docs.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ jobs:
3838
# The type of runner that the job will run on
3939
runs-on: ubuntu-latest
4040

41+
env:
42+
AVM_DOCS_NAME: ${{ github.ref_name }}
43+
4144
# Steps represent a sequence of tasks that will be executed as part of the job
4245
steps:
4346
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it

doc/CMakeLists.txt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,8 @@ add_custom_target(edown-escript
5858

5959
# Get the version tree name, tag if this is a tagged commit, otherwise get the current branch name.
6060
if ($ENV{CI})
61-
if (NOT (DEFINED ENV{GITHUB_BASE_REF}) AND ($ENV{GITHUB_REPOSITORY} STREQUAL "atomvm/AtomVM"))
62-
set(DOC_TREE_VERSION $ENV{GITHUB_REF_NAME})
63-
message("CI Publishing documentation for ${DOC_TREE_VERSION}")
64-
elseif ($ENV{GITHUB_REPOSITORY} STREQUAL "atomvm/AtomVM")
65-
set(DOC_TREE_VERSION $ENV{GITHUB_HEAD_REF})
66-
message("CI Test building documentation for ${DOC_TREE_VERSION}")
67-
else()
68-
set(DOC_TREE_VERSION $ENV{GITHUB_REF_NAME})
69-
message("CI Test building documentation for $ENV{GITHUB_REPOSITORY} on branch ${DOC_TREE_VERSION}")
70-
endif (NOT (DEFINED ENV{GITHUB_BASE_REF}) AND ($ENV{GITHUB_REPOSITORY} STREQUAL "atomvm/AtomVM"))
61+
set(DOC_TREE_VERSION $ENV{AVM_DOCS_NAME})
62+
message("CI building documentation for target branch ${DOC_TREE_VERSION}")
7163
else()
7264
execute_process(COMMAND "bash" "-c" "tag=$(git for-each-ref --points-at=HEAD --format='%(refname:lstrip=2)' refs/tags); ( [ $tag ] && echo $tag )|| git branch --show-current"
7365
OUTPUT_VARIABLE

0 commit comments

Comments
 (0)