build-docs #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-docs | |
on: | |
workflow_dispatch: | |
inputs: | |
profile: | |
description: 'Project profile' | |
required: true | |
version: | |
description: 'Project version' | |
required: true | |
semanticVersion: | |
description: 'Project semantic version' | |
required: false | |
hashVersion: | |
description: 'Project hash commit' | |
required: true | |
sha: | |
description: 'SHA commit id' | |
required: true | |
isRelease: | |
description: 'Is release' | |
required: false | |
default: 'false' | |
antoraBuildDir: | |
description: 'Specifics Antora output dir per profile' | |
required: true | |
javaDist: | |
description: 'Java distribution' | |
required: false | |
default: 'temurin' | |
javaVersion: | |
description: 'Java version' | |
required: false | |
default: '17' | |
jobs: | |
context: | |
name: Evaluate context | |
runs-on: ubuntu-latest | |
steps: | |
- name: Evaluate context | |
id: context | |
shell: bash | |
run: | | |
if [[ '${{ inputs.isRelease }}' == 'true' ]]; then | |
docBranch="docs/${{ inputs.profile }}/v${{ inputs.version }}" | |
docVersion="${{ inputs.version }}" | |
commitVersion="${{ inputs.version }}-${{ inputs.hashVersion }}" | |
else | |
docBranch="docs/main" | |
docVersion="main" | |
commitVersion="main-${{ inputs.hashVersion }}" | |
fi | |
docProfile="${{ inputs.profile }}:docs" | |
docOutDir="./antora/${{ inputs.profile }}" | |
echo docProfile=$docProfile >> $GITHUB_OUTPUT | |
echo docBranch=$docBranch >> $GITHUB_OUTPUT | |
echo docVersion=$docVersion >> $GITHUB_OUTPUT | |
echo docOutDir=$docOutDir >> $GITHUB_OUTPUT | |
echo docBuildDir=${{ inputs.antoraBuildDir }} >> $GITHUB_OUTPUT | |
echo ciMsg="${{ inputs.profile }} documentation [$commitVersion]" >> $GITHUB_OUTPUT | |
outputs: | |
docProfile: ${{ steps.context.outputs.docProfile }} | |
docBranch: ${{ steps.context.outputs.docBranch }} | |
docVersion: ${{ steps.context.outputs.docVersion }} | |
docOutDir: ${{ steps.context.outputs.docOutDir }} | |
docBuildDir: ${{ steps.context.outputs.docBuildDir }} | |
ciMsg: ${{ steps.context.outputs.ciMsg }} | |
build: | |
name: Build ${{ inputs.profile }} doc | |
runs-on: ubuntu-latest | |
needs: context | |
steps: | |
- uses: actions/[email protected] | |
with: | |
ref: ${{ inputs.sha }} | |
token: ${{ secrets.OSS_GITHUB_TOKEN }} | |
fetch-depth: 0 | |
submodules: 'true' | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v5 | |
with: | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_tag_gpgsign: false | |
git_push_gpgsign: false | |
gpg_private_key: ${{ secrets.CI_GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.CI_GPG_PASSPHARSE }} | |
- uses: actions/[email protected] | |
with: | |
distribution: ${{ inputs.javaDist }} | |
java-version: ${{ inputs.javaVersion }} | |
cache: 'gradle' | |
- name: Generate jOOQ test schema | |
shell: bash | |
run: ./gradlew :integtest:pg:generateJooq | |
- name: Build docs | |
shell: bash | |
run: | | |
./gradlew antoraDoc \ | |
-Pprofile=${{ needs.context.outputs.docProfile }} \ | |
-PdocVersion=${{ needs.context.outputs.docVersion }} \ | |
-Pversion=${{ inputs.version }} \ | |
-PsemanticVersion=${{ inputs.semanticVersion }} \ | |
-PbuildHash=${{ inputs.hashVersion }} \ | |
-PbuildBy="GitHub-Action" | |
- name: Sync changes to Git branch [${{ needs.context.outputs.docBranch }}] | |
shell: bash | |
run: | | |
git fetch | |
git checkout docs/main | |
rm -rf ${{ needs.context.outputs.docOutDir }} \ | |
&& mkdir ${{ needs.context.outputs.docOutDir }} \ | |
&& touch ${{ needs.context.outputs.docOutDir }}/.gitkeep \ | |
&& cp -rf ./${{ needs.context.outputs.docBuildDir }}/* ${{ needs.context.outputs.docOutDir }} | |
git add . | |
git diff-index --quiet HEAD || git commit -am "Update ${{ needs.context.outputs.ciMsg }}" | |
if [[ '${{ inputs.isRelease }}' == 'true' ]]; then | |
git tag -sf -am "Release ${{ needs.context.outputs.ciMsg }}" ${{ needs.context.outputs.docBranch }} | |
fi | |
git push --follow-tags | |
deploy-site: | |
name: Build and Deploy site | |
runs-on: ubuntu-latest | |
needs: [ context, build ] | |
env: | |
PROJECT_NAME: jooqx # No space | |
PROJECT_REPO: zero88/jooqx | |
PROJECT_REF: gh-pages | |
WEBDOCS_REPO: zero88/jooqx-webdocs | |
WEBDOCS_REF: main | |
steps: | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16' | |
- name: Checkout webdocs | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ env.WEBDOCS_REPO }} | |
ref: ${{ env.WEBDOCS_REF }} | |
path: webdocs | |
- name: Build web site | |
shell: bash | |
run: | | |
cd webdocs | |
yarn install | |
yarn antora --fetch antora-playbook.yml --stacktrace | |
- name: Checkout ${{ env.PROJECT_NAME }} | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ env.PROJECT_REPO }} | |
ref: ${{ env.PROJECT_REF }} | |
path: ${{ env.PROJECT_NAME }} | |
- name: Import GPG key | |
uses: crazy-max/ghaction-import-gpg@v5 | |
with: | |
git_user_signingkey: true | |
git_commit_gpgsign: true | |
git_tag_gpgsign: false | |
git_push_gpgsign: false | |
gpg_private_key: ${{ secrets.CI_GPG_PRIVATE_KEY }} | |
passphrase: ${{ secrets.CI_GPG_PASSPHARSE }} | |
workdir: ${{ env.PROJECT_NAME }} | |
- name: Sync changes to Git branch [${{ env.PROJECT_REF }}] | |
shell: bash | |
run: | | |
rm -rf ${{ env.PROJECT_NAME }}/docs \ | |
&& mkdir -p ${{ env.PROJECT_NAME }}/docs \ | |
&& cp -rf webdocs/build/* webdocs/build/.[^.]* ${{ env.PROJECT_NAME }}/docs | |
cd ${{ env.PROJECT_NAME }} | |
git add . | |
git diff-index --quiet HEAD || git commit -am "Deploy ${{ needs.context.outputs.ciMsg }} documentation" | |
git push -u origin ${{ env.PROJECT_REF }} |