You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
96 lines
4.2 KiB
96 lines
4.2 KiB
name: Build and Deploy Documentation |
|
run-name: ${{ format('{0} ({1})', github.workflow, github.event.inputs.build-refname || 'all') }} |
|
on: |
|
workflow_dispatch: |
|
inputs: |
|
build-refname: |
|
description: Enter git refname to build (e.g., 1.0.x). |
|
required: false |
|
build-sha: |
|
description: Enter the SHA to build (e.g. 82c97891569821a7f91a77ca074232e0b54ca7a5) |
|
required: false |
|
build-version: |
|
description: Enter the version being build (e.g. 1.0.3-SNAPSHOT) |
|
required: false |
|
push: |
|
branches: docs-build |
|
permissions: read-all |
|
jobs: |
|
build-and-deploy-docs: |
|
name: Build and Deploy Documentation |
|
if: github.repository_owner == 'spring-projects' |
|
runs-on: ${{ vars.UBUNTU_SMALL || 'ubuntu-latest' }} |
|
steps: |
|
- name: Check Out |
|
uses: actions/checkout@v4 |
|
with: |
|
fetch-depth: 0 |
|
- name: Rest Build Reference to SHA |
|
if: ${{ github.event.inputs.build-refname != '' && github.event.inputs.build-sha != '' }} |
|
run: | |
|
git update-ref refs/remotes/origin/${{ github.event.inputs.build-refname }} ${{ github.event.inputs.build-sha }} |
|
git update-ref refs/heads/${{ github.event.inputs.build-refname }} ${{ github.event.inputs.build-sha }} |
|
- name: Fetch Main Branch |
|
run: git fetch origin ${{ github.event.repository.default_branch }}:main |
|
- name: Set Up Node |
|
uses: actions/setup-node@v4 |
|
with: |
|
node-version: 20 |
|
- name: Check Out 'package.json' From Main |
|
run: node run.js --only-checkout |
|
- name: Cache Files |
|
uses: actions/cache@v4 |
|
with: |
|
key: antora-${{ hashFiles('package-lock.json', 'antora-playbook.yml') }} |
|
path: | |
|
~/.npm |
|
~/.cache/antora |
|
- name: Install and Run Antora |
|
env: |
|
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} |
|
ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} |
|
COMMERCIAL_REPO_USERNAME: ${{ secrets.COMMERCIAL_ARTIFACTORY_USERNAME }} |
|
COMMERCIAL_REPO_PASSWORD: ${{ secrets.COMMERCIAL_ARTIFACTORY_PASSWORD }} |
|
COMMERCIAL_SNAPSHOT_REPO_URL: ${{ vars.COMMERCIAL_SNAPSHOT_REPO_URL }} |
|
COMMERCIAL_RELEASE_REPO_URL: ${{ vars.COMMERCIAL_RELEASE_REPO_URL }} |
|
BUILD_REFNAME: ${{ github.event.inputs.build-refname }} |
|
BUILD_VERSION: ${{ github.event.inputs.build-version }} |
|
run: node run.js --no-checkout |
|
- name: Sync OSS Documentation |
|
if: ${{ !vars.COMMERCIAL }} |
|
uses: spring-io/spring-doc-actions/rsync-antora-reference@v0.0.21 |
|
with: |
|
docs-username: ${{ secrets.DOCS_USERNAME }} |
|
docs-host: ${{ secrets.DOCS_HOST }} |
|
docs-ssh-key: ${{ secrets.DOCS_SSH_KEY }} |
|
docs-ssh-host-key: ${{ secrets.DOCS_SSH_HOST_KEY }} |
|
httpdocs-path: /spring-boot/antora/ |
|
env: |
|
BUILD_REFNAME: ${{ github.event.inputs.build-refname }} |
|
BUILD_VERSION: ${{ github.event.inputs.build-version }} |
|
- name: Authenticate for commercial distribution |
|
if: ${{ vars.COMMERCIAL }} |
|
uses: 'google-github-actions/auth@v2.1.0' |
|
with: |
|
credentials_json: '${{ secrets.COMMERCIAL_DOCS_GCP_BUCKET_JSON }}' |
|
- name: Sync commercial Documentation |
|
if: ${{ vars.COMMERCIAL }} |
|
uses: 'google-github-actions/upload-cloud-storage@v2.1.0' |
|
with: |
|
path: 'build/site' |
|
destination: '${{ vars.COMMERCIAL_DOCS_HOST }}/spring-boot' |
|
parent: false |
|
- name: Bust Cloudflare Cache |
|
uses: spring-io/spring-doc-actions/bust-cloudflare-antora-cache@v0.0.21 |
|
with: |
|
context-root: spring-boot |
|
context-path: / |
|
cloudflare-zone-id: ${{ (vars.COMMERCIAL && secrets.COMMERCIAL_CLOUDFLARE_ZONE_ID) || secrets.CLOUDFLARE_ZONE_ID }} |
|
cloudflare-cache-token: ${{ secrets.CLOUDFLARE_CACHE_TOKEN }} |
|
- name: Send Notification |
|
if: failure() |
|
uses: ./.github/actions/send-notification |
|
with: |
|
run-name: ${{ vars.COMMERCIAL && format('{0} | Build and Deploy Commerical Docs', github.ref_name) || format('{0} | Build and Deploy OSS Docs', github.ref_name) }} |
|
status: ${{ job.status }} |
|
webhook-url: ${{ secrets.GOOGLE_CHAT_WEBHOOK_URL }}
|
|
|