|
| 1 | +# Simple workflow for deploying static content to GitHub Pages |
| 2 | +name: Deploy static content to Pages |
| 3 | + |
| 4 | +on: |
| 5 | + # Runs on pushes targeting the default branch |
| 6 | + push: |
| 7 | + branches: ["main"] |
| 8 | + |
| 9 | + # Allows you to run this workflow manually from the Actions tab |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + pages: write |
| 16 | + id-token: write |
| 17 | + |
| 18 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 19 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 20 | +concurrency: |
| 21 | + group: "pages" |
| 22 | + cancel-in-progress: false |
| 23 | + |
| 24 | +jobs: |
| 25 | + generate-docs: |
| 26 | + runs-on: ubuntu-latest |
| 27 | + |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + |
| 32 | + - name: Set up JDK |
| 33 | + uses: actions/setup-java@v3 |
| 34 | + with: |
| 35 | + distribution: 'temurin' |
| 36 | + java-version: '21' |
| 37 | + |
| 38 | + - name: Set up Gradle |
| 39 | + uses: gradle/actions/setup-gradle@v3 |
| 40 | + |
| 41 | + - name: Generate Dokka Documentation |
| 42 | + run: ./gradlew dokkaHtml |
| 43 | + |
| 44 | + - name: Zip Generated Documentation |
| 45 | + run: | |
| 46 | + cd kv-color-picker/build/docs/dokkaHtml |
| 47 | + zip -r ../../../../kv-color-picker-dokka.zip . |
| 48 | +
|
| 49 | + - name: Remove all files except documentation |
| 50 | + run: | |
| 51 | + shopt -s extglob |
| 52 | + rm -rf !(kv-color-picker-dokka.zip|.git) |
| 53 | +
|
| 54 | + - name: Checkout to gh-pages |
| 55 | + run: | |
| 56 | + git config --global user.name "github-actions[bot]" |
| 57 | + git config --global user.email "github-actions[bot]@users.noreply.github.com" |
| 58 | + |
| 59 | + # Check if gh-pages exists |
| 60 | + if git ls-remote --exit-code --heads origin gh-pages; then |
| 61 | + git fetch origin gh-pages |
| 62 | + git checkout gh-pages |
| 63 | + git rm -rf . |
| 64 | + else |
| 65 | + git checkout --orphan gh-pages |
| 66 | + fi |
| 67 | +
|
| 68 | + - name: Extract documentation |
| 69 | + run: | |
| 70 | + unzip kv-color-picker-dokka.zip |
| 71 | + rm -rf kv-color-picker-dokka.zip |
| 72 | + rm -rf .gradle |
| 73 | +
|
| 74 | + touch .nojekyll # Prevent GitHub from treating it as a Jekyll site |
| 75 | + git add . |
| 76 | + git commit -m "Deploy Dokka documentation" || echo "No changes to commit" |
| 77 | +
|
| 78 | + - name: Push Changes with SSH |
| 79 | + run: | |
| 80 | + eval "$(ssh-agent -s)" |
| 81 | + ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}" |
| 82 | + git push [email protected]:KvColorPalette/KvColorPicker-Android.git gh-pages |
0 commit comments