dist-docs.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. name: dist-docs
  2. on:
  3. push:
  4. branches:
  5. - master
  6. tags:
  7. - '*'
  8. permissions:
  9. contents: write
  10. pages: write
  11. concurrency:
  12. group: crown-package-${{ github.ref }}
  13. cancel-in-progress: false
  14. jobs:
  15. detect:
  16. runs-on: ubuntu-22.04
  17. outputs:
  18. is_tag: ${{ steps.detect.outputs.is_tag }}
  19. version: ${{ steps.detect.outputs.version }}
  20. branch: ${{ steps.detect.outputs.branch }}
  21. steps:
  22. - name: prepare
  23. uses: actions/checkout@v4
  24. with:
  25. fetch-depth: 0
  26. ref: ${{ github.ref }}
  27. - name: detect
  28. id: detect
  29. run: |
  30. set -euo pipefail
  31. if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
  32. echo "is_tag=true" >> $GITHUB_OUTPUT
  33. echo "version=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
  34. echo "branch=" >> $GITHUB_OUTPUT
  35. else
  36. echo "is_tag=false" >> $GITHUB_OUTPUT
  37. if [ -n "${GITHUB_HEAD_REF:-}" ]; then
  38. BRANCH="${GITHUB_HEAD_REF}"
  39. else
  40. if [[ "${GITHUB_REF}" == refs/heads/* ]]; then
  41. BRANCH="${GITHUB_REF#refs/heads/}"
  42. else
  43. BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || true)"
  44. if [ -z "${BRANCH:-}" ] || [ "${BRANCH}" = "HEAD" ]; then
  45. BRANCH="$(git name-rev --name-only HEAD 2>/dev/null || true)"
  46. fi
  47. BRANCH="${BRANCH#remotes/origin/}"
  48. fi
  49. fi
  50. echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
  51. if [[ "${BRANCH}" == "master" ]]; then
  52. echo "version=master" >> $GITHUB_OUTPUT
  53. else
  54. echo "version=${BRANCH}" >> $GITHUB_OUTPUT
  55. fi
  56. fi
  57. docs:
  58. needs: detect
  59. runs-on: ubuntu-22.04
  60. env:
  61. IS_TAG: ${{ needs.detect.outputs.is_tag }}
  62. VERSION: ${{ needs.detect.outputs.version }}
  63. BRANCH: ${{ needs.detect.outputs.branch }}
  64. steps:
  65. - name: prepare
  66. uses: actions/checkout@v4
  67. with:
  68. fetch-depth: 0
  69. ref: ${{ github.ref }}
  70. - name: detect
  71. run: |
  72. set -euo pipefail
  73. echo "IS_TAG=${IS_TAG}" >> $GITHUB_ENV
  74. echo "VERSION=${VERSION}" >> $GITHUB_ENV
  75. echo "BRANCH=${BRANCH}" >> $GITHUB_ENV
  76. - name: install-deps
  77. shell: bash
  78. run: |
  79. set -euo pipefail
  80. sudo apt-get update
  81. sudo apt-get install python3-sphinx
  82. - name: build-and-publish
  83. shell: bash
  84. run: |
  85. set -euo pipefail
  86. git config user.name "github-actions[bot]"
  87. git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
  88. if [ "$IS_TAG" = "true" ]; then
  89. ./scripts/dist/docs.sh --noconfirm --push
  90. else
  91. ./scripts/dist/docs.sh --noconfirm --push master
  92. fi