|
| 1 | +name: GTIRB Docs |
| 2 | +on: [push] |
| 3 | + |
| 4 | +jobs: |
| 5 | + docker: |
| 6 | + runs-on: ubuntu-latest |
| 7 | + permissions: |
| 8 | + packages: write |
| 9 | + strategy: |
| 10 | + matrix: |
| 11 | + os: [focal] |
| 12 | + include: |
| 13 | + - os: focal |
| 14 | + file_suffix: ubuntu20 |
| 15 | + outputs: |
| 16 | + image_tag: ${{ steps.vars.outputs.image_tag }} |
| 17 | + image_path: ${{ steps.vars.outputs.image_path }} |
| 18 | + steps: |
| 19 | + # We must generate output variables here in order to ensure the |
| 20 | + # reference is lowercase, even if the repository reference is not |
| 21 | + # (e.g., because of the organization "GrammaTech"). |
| 22 | + # For the tag, we replace forward slashes with hyphens and use the tag |
| 23 | + # the "latest" for the "master" branch. |
| 24 | + # We'd like to just generate the environment variables, but the `env` |
| 25 | + # context is not available in the "jobs.<id>.container" field, despite |
| 26 | + # what the Context Availability documentation says. See: |
| 27 | + # https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability |
| 28 | + - id: vars |
| 29 | + run: | |
| 30 | + export IMAGE_TAG=$([ "${{ github.ref_name }}" == "master" ] && echo latest || echo ${{ github.ref_name }} | sed -e "s/\//-/g") |
| 31 | + echo "image_tag=$IMAGE_TAG" >> $GITHUB_ENV |
| 32 | + echo "image_tag=$IMAGE_TAG" >> $GITHUB_OUTPUT |
| 33 | + export IMAGE_PATH=$(echo ghcr.io/${{ github.repository }}/ | awk '{print tolower($0)}') |
| 34 | + echo "image_path=$IMAGE_PATH" >> $GITHUB_ENV |
| 35 | + echo "image_path=$IMAGE_PATH" >> $GITHUB_OUTPUT |
| 36 | + - uses: actions/checkout@master |
| 37 | + - name: Kaniko build |
| 38 | + uses: aevea/action-kaniko@v0.9.0 |
| 39 | + with: |
| 40 | + registry: ghcr.io |
| 41 | + image: ${{ matrix.os }} |
| 42 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + cache: true |
| 44 | + cache_registry: ${{ matrix.os }}-cache |
| 45 | + tag: ${{ env.image_tag }} |
| 46 | + build_file: .ci/Dockerfile.${{ matrix.file_suffix }} |
| 47 | + |
| 48 | + docs: |
| 49 | + runs-on: ubuntu-latest |
| 50 | + permissions: |
| 51 | + packages: read |
| 52 | + strategy: |
| 53 | + matrix: |
| 54 | + os: [focal] |
| 55 | + needs: docker |
| 56 | + container: ${{ needs.docker.outputs.image_path }}${{ matrix.os }}:${{ needs.docker.outputs.image_tag }} |
| 57 | + steps: |
| 58 | + - name: Checkout |
| 59 | + uses: actions/checkout@v3 |
| 60 | + - name: Generate documentation |
| 61 | + run: | |
| 62 | + cmake -DGTIRB_ENABLE_TESTS=OFF -B build . |
| 63 | + cd build/python |
| 64 | + pip install -e '.[doc]' |
| 65 | + cd .. |
| 66 | + cmake .. |
| 67 | + make doc |
| 68 | + mv doc/html ../public |
| 69 | + - name: Upload GitHub Pages artifact |
| 70 | + uses: actions/upload-pages-artifact@v1.0.8 |
| 71 | + with: |
| 72 | + path: public |
| 73 | + |
| 74 | + deploy-pages: |
| 75 | + needs: docs |
| 76 | + if: github.ref == 'refs/heads/master' |
| 77 | + permissions: |
| 78 | + pages: write |
| 79 | + id-token: write |
| 80 | + |
| 81 | + environment: |
| 82 | + name: github-pages |
| 83 | + url: ${{ steps.deployment.outputs.page_url }} |
| 84 | + |
| 85 | + runs-on: ubuntu-latest |
| 86 | + steps: |
| 87 | + - name: Deploy to GitHub Pages |
| 88 | + id: deployment |
| 89 | + uses: actions/deploy-pages@v2 |
0 commit comments