|
| 1 | +name: Publish API Documentation on Release |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + pages: write |
| 6 | + id-token: write |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + tags: |
| 11 | + - 'v*.*.*' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +concurrency: |
| 15 | + group: 'api-docs-release' |
| 16 | + cancel-in-progress: false |
| 17 | + |
| 18 | +jobs: |
| 19 | + build-and-deploy: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + environment: |
| 22 | + name: github-pages |
| 23 | + url: ${{ steps.deployment.outputs.page_url }} |
| 24 | + |
| 25 | + steps: |
| 26 | + - name: Checkout code |
| 27 | + uses: actions/checkout@v4 |
| 28 | + with: |
| 29 | + fetch-depth: 0 |
| 30 | + |
| 31 | + - name: Setup Node.js |
| 32 | + uses: actions/setup-node@v4 |
| 33 | + with: |
| 34 | + node-version: '18' |
| 35 | + cache: 'yarn' |
| 36 | + |
| 37 | + - name: Setup Ruby |
| 38 | + uses: ruby/setup-ruby@v1 |
| 39 | + with: |
| 40 | + ruby-version: '3.1' |
| 41 | + bundler-cache: true |
| 42 | + |
| 43 | + - name: Install Node dependencies |
| 44 | + run: yarn install --frozen-lockfile |
| 45 | + |
| 46 | + - name: Extract version from tag |
| 47 | + id: version |
| 48 | + run: | |
| 49 | + VERSION=${GITHUB_REF#refs/tags/v} |
| 50 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 51 | + echo "Publishing documentation for version $VERSION" |
| 52 | +
|
| 53 | + - name: Build types and generate API docs |
| 54 | + run: | |
| 55 | + echo "Building API documentation for version ${{ steps.version.outputs.version }}" |
| 56 | + yarn docs:api |
| 57 | +
|
| 58 | + - name: Add version info to documentation |
| 59 | + run: | |
| 60 | + sed -i "1i---\nlayout: default\ntitle: \"Datadog Browser SDK v${{ steps.version.outputs.version }}\"\nversion: \"${{ steps.version.outputs.version }}\"\n---\n" docs/index.md |
| 61 | +
|
| 62 | + - name: Setup Pages |
| 63 | + uses: actions/configure-pages@v4 |
| 64 | + |
| 65 | + - name: Build with Jekyll |
| 66 | + run: | |
| 67 | + bundle exec jekyll build --source docs --destination _site |
| 68 | + env: |
| 69 | + JEKYLL_ENV: production |
| 70 | + |
| 71 | + - name: Upload artifact |
| 72 | + uses: actions/upload-pages-artifact@v3 |
| 73 | + |
| 74 | + - name: Deploy to GitHub Pages |
| 75 | + id: deployment |
| 76 | + uses: actions/deploy-pages@v4 |
| 77 | + |
| 78 | + - name: Create deployment summary |
| 79 | + run: | |
| 80 | + echo "## 📚 API Documentation Published" >> $GITHUB_STEP_SUMMARY |
| 81 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 82 | + echo "**Version:** ${{ steps.version.outputs.version }}" >> $GITHUB_STEP_SUMMARY |
| 83 | + echo "**URL:** ${{ steps.deployment.outputs.page_url }}" >> $GITHUB_STEP_SUMMARY |
| 84 | + echo "**Tag:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY |
| 85 | + echo "" >> $GITHUB_STEP_SUMMARY |
0 commit comments