Skip to content

Merge pull request #175 from stytchauth/jordan/SDK-1727-non-null-upda… #63

Merge pull request #175 from stytchauth/jordan/SDK-1727-non-null-upda…

Merge pull request #175 from stytchauth/jordan/SDK-1727-non-null-upda… #63

Workflow file for this run

name: Versioned Docs
on:
workflow_dispatch:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.ref != 'refs/heads/main' || github.run_number }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull') }}
jobs:
set-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
matrix-values: ${{ steps.set-matrix.outputs.matrix-values }}
steps:
- uses: actions/checkout@v3
- run: git fetch --tags -f origin
- uses: actions/checkout@v3
with:
ref: docs
path: docs
- id: set-matrix
run: |
matrix_values=''
for ref in $(git tag --list); do
docs_path="docs/docs/olderVersions/$ref"
mkdir -p $docs_path
if [[ $(find $docs_path -type d -empty) ]]; then
matrix_values+="{\"ref\":\"$ref\",\"ref_label\":\"$ref\"},"
fi
done
matrix_values+='{"ref":"main","ref_label":"main"}'
echo "matrix-values=[${matrix_values}]" >> $GITHUB_OUTPUT
echo "matrix={\"include\":[${matrix_values}]}" >> $GITHUB_OUTPUT
docs:
needs: set-matrix
strategy:
matrix: ${{ fromJSON(needs.set-matrix.outputs.matrix) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ matrix.ref }}
path: main
- uses: actions/checkout@v3
with:
ref: docs
path: docs
- uses: actions/setup-java@v3
with:
distribution: zulu
java-version: 17
- name: Generate docs
env:
STYTCH_PUBLIC_TOKEN: 'abc123'
GOOGLE_OAUTH_CLIENT_ID: 'abc123'
STYTCH_B2B_PUBLIC_TOKEN: 'abc123'
STYTCH_B2B_ORG_ID: 'abc123'
PASSKEYS_DOMAIN: 'abc123'
STYTCH_UI_PUBLIC_TOKEN: 'abc123'
UI_GOOGLE_CLIENT_ID: 'abc123'
working-directory: main
run: ./gradlew dokkaHtmlMultiModule
- name: Zip docs site
run: |
cd main/docs
zip -r ../../Docs.zip .
cd -
- uses: actions/upload-artifact@v3
with:
name: ${{ matrix.ref_label }}
path: Docs.zip
publish:
needs: [set-matrix, docs]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: main
path: main
- uses: actions/checkout@v3
with:
ref: docs
path: docs
- uses: actions/download-artifact@v3
with:
path: artifacts
- name: Unzip
run: |
mkdir unzipped-docs
for ref in $(echo ${{ toJSON(needs.set-matrix.outputs.matrix-values) }} | jq -r '.[].ref_label'); do
unzipped_path="unzipped-docs/$ref"
mkdir -p "$unzipped_path"
unzip "artifacts/$ref/Docs.zip" -d "$unzipped_path"
if [ "$ref" = "main" ]; then
echo "extracting to root"
rsync -a "$unzipped_path/" docs/docs
else
echo "extracting to olderVersions"
rsync -a "$unzipped_path" docs/docs/olderVersions/
fi
done
- name: Update git config
working-directory: docs
run: |
git config --local user.name "CI"
git config --local user.email "[email protected]"
- name: Commit
working-directory: main
run: |
current_sha="$(git rev-parse @)"
cd ../docs
if [[ -z $(git status --porcelain) ]]; then exit 0; fi
git add --all
git commit -m "$current_sha"
git push