|
| 1 | +name: Build and Deploy Documentation |
| 2 | +run-name: ${{ format('{0} ({1})', github.workflow, github.event.inputs.build-refname || 'all') }} |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + build-refname: |
| 7 | + description: Enter git refname to build (e.g., 1.0.x). |
| 8 | + required: false |
| 9 | + build-version: |
| 10 | + description: Enter the version being build (e.g. 1.0.3-SNAPSHOT) |
| 11 | + required: false |
| 12 | + push: |
| 13 | + branches: docs-build |
| 14 | +permissions: read-all |
| 15 | +jobs: |
| 16 | + build-and-deploy-docs: |
| 17 | + name: Build and Deploy Documentation |
| 18 | + if: github.repository_owner == 'spring-projects' |
| 19 | + runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} |
| 20 | + steps: |
| 21 | + - name: Check Out |
| 22 | + uses: actions/checkout@v4 |
| 23 | + with: |
| 24 | + fetch-depth: 0 |
| 25 | + - name: Fetch Main Branch |
| 26 | + run: git fetch origin ${{ github.event.repository.default_branch }}:main |
| 27 | + - name: Set Up Node |
| 28 | + uses: actions/setup-node@v4 |
| 29 | + with: |
| 30 | + node-version: 20 |
| 31 | + - name: Check Out 'package.json' From Main |
| 32 | + run: node run.js --only-checkout |
| 33 | + - name: Cache Files |
| 34 | + uses: actions/cache@v4 |
| 35 | + with: |
| 36 | + key: antora-${{ hashFiles('package-lock.json', 'antora-playbook.yml') }} |
| 37 | + path: | |
| 38 | + ~/.npm |
| 39 | + ~/.cache/antora |
| 40 | + - name: Install and Run Antora |
| 41 | + env: |
| 42 | + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} |
| 43 | + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} |
| 44 | + BUILD_REFNAME: ${{ github.event.inputs.build-refname }} |
| 45 | + BUILD_VERSION: ${{ github.event.inputs.build-version }} |
| 46 | + run: node run.js --no-checkout |
| 47 | + - name: Sync Documentation |
| 48 | + uses: spring-io/spring-doc-actions/[email protected] |
| 49 | + with: |
| 50 | + docs-username: ${{ secrets.DOCS_USERNAME }} |
| 51 | + docs-host: ${{ secrets.DOCS_HOST }} |
| 52 | + docs-ssh-key: ${{ secrets.DOCS_SSH_KEY }} |
| 53 | + docs-ssh-host-key: ${{ secrets.DOCS_SSH_HOST_KEY }} |
| 54 | + httpdocs-path: /spring-restdocs/antora/ |
| 55 | + env: |
| 56 | + BUILD_REFNAME: ${{ github.event.inputs.build-refname }} |
| 57 | + BUILD_VERSION: ${{ github.event.inputs.build-version }} |
| 58 | + - name: Bust Cloudflare Cache |
| 59 | + uses: spring-io/spring-doc-actions/[email protected] |
| 60 | + with: |
| 61 | + context-root: spring-restdocs |
| 62 | + context-path: / |
| 63 | + cloudflare-zone-id: ${{ secrets.CLOUDFLARE_ZONE_ID }} |
| 64 | + cloudflare-cache-token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} |
| 65 | + - name: Send Notification |
| 66 | + if: failure() |
| 67 | + uses: ./.github/actions/send-notification |
| 68 | + with: |
| 69 | + run-name: ${{ format('{0} | Build and Deploy Docs', github.ref_name) }} |
| 70 | + status: ${{ job.status }} |
| 71 | + webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }} |
0 commit comments