CD #8
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: CD | |
on: | |
release: | |
types: [ published ] | |
workflow_dispatch: | |
inputs: | |
dry_run: | |
description: 'dry run' | |
type: boolean | |
default: true | |
jobs: | |
pre-flight-checks: | |
if: "!(contains(github.event.head_commit.message, '[cd skip]') || contains(github.event.head_commit.message, '[skip cd]'))" | |
runs-on: ubuntu-latest | |
steps: | |
- name: Print inputs | |
run: | | |
echo "dry_run: ${{ github.event.inputs.dry_run }}" | |
build-pages: | |
needs: [ pre-flight-checks ] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Randomness source code | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
path: main | |
- name: Checkout Randomness pages | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: gh-pages | |
# Required to push updated documentation to repository. | |
# If you get "Error: fatal: could not read Username for 'https://github.com': terminal prompts disabled", then | |
# the token has probably expired. | |
token: ${{ secrets.personal_access_token }} | |
- name: Set up Java | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Set up Gradle | |
uses: gradle/actions/setup-gradle@v4 | |
with: | |
add-job-summary: on-failure | |
- name: Extract version number | |
working-directory: main/ | |
run: echo "RANDOMNESS_VERSION=v$(cat gradle.properties | grep '^version=' | sed 's/^.*=//')" >> $GITHUB_ENV | |
- name: Generate new documentation | |
working-directory: main/ | |
run: ./gradlew dokkaHtml -Pdokka.pagesDir="${{ github.workspace }}/gh-pages/" | |
- name: Move new documentation into gh-pages | |
run: | | |
rm -rf gh-pages/* | |
mv main/build/dokka/html/* gh-pages/ | |
- name: Push new documentation | |
if: ${{ github.event.inputs.dry_run == 'false' }} | |
working-directory: gh-pages/ | |
run: | | |
git config --global user.name "FWDekkerBot" | |
git config --global user.email "bot@fwdekker.com" | |
git add --all | |
git commit -m "Update for ${RANDOMNESS_VERSION}" | |
git push origin gh-pages |