deploy-dev-docs.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. name: Deploy developer docs
  2. on:
  3. push:
  4. branches: [ master, docs ]
  5. paths:
  6. - 'src/**'
  7. - 'docs/dev/**'
  8. - '.github/workflows/deploy-dev-docs.yml'
  9. workflow_dispatch:
  10. jobs:
  11. build-and-deploy:
  12. runs-on: ubuntu-22.04
  13. steps:
  14. - name: Install dependencies
  15. run: |
  16. sudo apt-get --yes --quiet update
  17. sudo apt-get --yes --no-install-recommends install doxygen
  18. pip install \
  19. mkdocs \
  20. mkdocs-material \
  21. git+https://github.com/veracioux/mkdoxy@v1.0.0
  22. - name: Checkout flameshot source
  23. uses: actions/checkout@v4
  24. with:
  25. path: 'flameshot'
  26. - name: Build docs
  27. working-directory: ${{github.workspace}}/flameshot/docs/dev
  28. run: |
  29. make build
  30. - name: Checkout flameshot website
  31. uses: actions/checkout@v4
  32. with:
  33. repository: 'flameshot-org/flameshot-org.github.io'
  34. ref: 'gh-pages'
  35. path: 'website'
  36. - name: Configure git credentials for website repo
  37. working-directory: ${{github.workspace}}/website
  38. run: |
  39. git config user.name "GitHub Actions"
  40. git config user.email "github-actions-bot@users.noreply.github.com"
  41. git config http.https://github.com/.extraheader 'AUTHORIZATION basic ${{secrets.TOKEN_PUSH_TO_WEBSITE_REPO}}'
  42. git remote add destination "https://x-access-token:${{secrets.TOKEN_PUSH_TO_WEBSITE_REPO}}@github.com/flameshot-org/flameshot-org.github.io"
  43. - name: Add developer docs to website deployment
  44. working-directory: ${{github.workspace}}/website
  45. run: |
  46. # Create empty dev-docs-staging branch
  47. git checkout --orphan dev-docs-staging
  48. git rm -r --cached .
  49. rm -rf docs/dev
  50. # Copy generated docs over
  51. mkdir -p docs
  52. mv "${{github.workspace}}/flameshot/docs/dev/output" \
  53. "./docs/dev"
  54. # Commit docs/dev to the dev-docs-staging branch
  55. git add docs/dev
  56. HASH="$(git --git-dir="${{github.workspace}}/flameshot/.git" rev-parse HEAD)"
  57. git commit --message "Add developer docs from flameshot@$HASH"
  58. # Apply changes to gh-pages
  59. git checkout --force gh-pages
  60. git checkout dev-docs-staging -- docs/dev
  61. # Commit (we use `|| true` because the commit could be empty and thus fail)
  62. git commit --message "Add developer docs from flameshot@$HASH" || true
  63. - name: Push to website repo
  64. working-directory: ${{github.workspace}}/website
  65. run: |
  66. git push --force destination dev-docs-staging
  67. git push destination gh-pages