|
4 | 4 | push: |
5 | 5 | tags: |
6 | 6 | - '*' |
| 7 | + branches: |
| 8 | + - main |
7 | 9 | workflow_dispatch: |
8 | 10 |
|
9 | 11 | jobs: |
10 | 12 | doxygen: |
11 | 13 | runs-on: ubuntu-latest |
12 | 14 |
|
| 15 | + env: |
| 16 | + DOC_BASE: build/doc/docs |
| 17 | + |
13 | 18 | steps: |
14 | | - - name: Checkout repository |
15 | | - uses: actions/checkout@v3 |
16 | | - |
17 | | - - name: Install Doxygen |
18 | | - run: sudo apt-get install doxygen graphviz -y |
19 | | - |
20 | | - - name: Generate Doxygen configuration and build it |
21 | | - run: | |
22 | | - TAG_NAME=$(echo $GITHUB_REF | sed 's/refs\/tags\///') |
23 | | - mkdir -p build/doc/docs/$TAG_NAME && cd build && cmake -D BUILD_DOCUMENTATION=ON -D SKIP_CXX_BUILD=ON .. && make doc |
24 | | - echo "Created folder for documentation:" |
25 | | - ls doc/docs |
26 | | -
|
27 | | - - name: Move contents of html folder one level up |
28 | | - run: | |
29 | | - TAG_NAME=$(echo $GITHUB_REF | sed 's/refs\/tags\///') |
30 | | - mv build/doc/docs/$TAG_NAME/html/* build/doc/docs/$TAG_NAME/ |
31 | | -
|
32 | | - - name: Create index.html for redirect |
33 | | - run: | |
34 | | - TAG_NAME=$(echo $GITHUB_REF | sed 's/refs\/tags\///') |
35 | | - URL="https://frankarobotics.github.io/libfranka/${TAG_NAME}/" |
36 | | - echo $URL |
37 | | - echo "<html><head><meta http-equiv=\"refresh\" content=\"0; url=$URL\"></head></html>" > build/doc/docs/index.html |
38 | | -
|
39 | | - - name: Deploy to GitHub Pages |
40 | | - uses: peaceiris/actions-gh-pages@v3 |
41 | | - with: |
42 | | - github_token: ${{ secrets.GITHUB_TOKEN }} |
43 | | - publish_branch: gh-pages |
44 | | - publish_dir: build/doc/docs |
45 | | - keep_files: true |
| 19 | + - name: Checkout repository |
| 20 | + uses: actions/checkout@v3 |
| 21 | + with: |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: | |
| 26 | + set -e |
| 27 | + sudo apt-get update |
| 28 | + sudo apt-get install -y doxygen graphviz cmake |
| 29 | +
|
| 30 | + - name: Determine documentation tag |
| 31 | + id: doc_tag |
| 32 | + run: | |
| 33 | + set -e |
| 34 | +
|
| 35 | + if [[ "$GITHUB_REF" == refs/tags/* ]]; then |
| 36 | + echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT |
| 37 | + elif [[ "$GITHUB_REF" == refs/heads/main ]]; then |
| 38 | + echo "TAG_NAME=latest" >> $GITHUB_OUTPUT |
| 39 | + else |
| 40 | + echo "Unsupported ref: $GITHUB_REF" >&2 |
| 41 | + exit 1 |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Build documentation |
| 45 | + run: | |
| 46 | + set -e |
| 47 | +
|
| 48 | + TAG_NAME="${{ steps.doc_tag.outputs.TAG_NAME }}" |
| 49 | + DOC_DIR="${DOC_BASE}/$TAG_NAME" |
| 50 | +
|
| 51 | + echo "Using documentation tag: $TAG_NAME" |
| 52 | +
|
| 53 | + # Clean latest deployment if rebuilding latest |
| 54 | + if [[ "$TAG_NAME" == "latest" ]]; then |
| 55 | + rm -rf "$DOC_DIR" |
| 56 | + fi |
| 57 | +
|
| 58 | + mkdir -p "$DOC_DIR" |
| 59 | +
|
| 60 | + cd build || exit 1 |
| 61 | +
|
| 62 | + cmake -D BUILD_DOCUMENTATION=ON -D SKIP_CXX_BUILD=ON .. |
| 63 | + make doc |
| 64 | +
|
| 65 | + - name: Normalize HTML structure |
| 66 | + run: | |
| 67 | + set -e |
| 68 | +
|
| 69 | + TAG_NAME="${{ steps.doc_tag.outputs.TAG_NAME }}" |
| 70 | + DOC_DIR="${DOC_BASE}/$TAG_NAME" |
| 71 | + SRC="${DOC_DIR}/html" |
| 72 | +
|
| 73 | + if [[ -d "$SRC" ]]; then |
| 74 | + mv "$SRC"/* "$DOC_DIR"/ |
| 75 | + rm -rf "$SRC" |
| 76 | + else |
| 77 | + echo "HTML directory not found — skipping" |
| 78 | + fi |
| 79 | +
|
| 80 | + - name: Create redirect index |
| 81 | + run: | |
| 82 | + TAG_NAME="${{ steps.doc_tag.outputs.TAG_NAME }}" |
| 83 | +
|
| 84 | + URL="https://frankarobotics.github.io/libfranka/${TAG_NAME}/" |
| 85 | +
|
| 86 | + echo "<html><head><meta http-equiv=\"refresh\" content=\"0; url=$URL\"></head></html>" \ |
| 87 | + > "${DOC_BASE}/index.html" |
| 88 | +
|
| 89 | + - name: Deploy to GitHub Pages |
| 90 | + uses: peaceiris/actions-gh-pages@v3 |
| 91 | + with: |
| 92 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 93 | + publish_branch: gh-pages |
| 94 | + publish_dir: ${{ env.DOC_BASE }} |
| 95 | + keep_files: true |
0 commit comments