From 7e792b2770c2d9da48b3e4ec38d60bd2d24886af Mon Sep 17 00:00:00 2001 From: Amir Abbas Mousavian Date: Sat, 16 Sep 2023 16:27:17 +0330 Subject: [PATCH] chore: Update DocC workflow --- .github/workflows/docc.yml | 82 +++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/.github/workflows/docc.yml b/.github/workflows/docc.yml index f69c33c..a54665f 100644 --- a/.github/workflows/docc.yml +++ b/.github/workflows/docc.yml @@ -1,50 +1,52 @@ -name: Docs - +name: Build Swift DocC and publish on GitHub Pages + on: push: + # If you wanted to only trigger this flow on certain branches, + # specify them here in + # branches: + # alternatively, you can trigger docs only on new tags pushed: tags: - - '[0-9]+.[0-9]+.[0-9]+' - workflow_dispatch: - -# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages -permissions: - contents: read - pages: write - id-token: write - -# Allow one concurrent deployment + - '[0-9]+.[0-9]+.[0-9]+' + +# `concurrency` specifices how this action is run. +# Setting concurrency group makes it so that only one build process runs at a time. concurrency: group: "pages" - cancel-in-progress: true - + cancel-in-progress: false + +env: + # Build target specifies which target in your Swift Package to build documentation for. + # To build all targets, remove this env variable, + # and remove --target arg in the building step below. + BUILD_TARGET: JWSETKit + jobs: - docs: + build: runs-on: macos-13 - + steps: - - uses: actions/checkout@v3 - - name: Set up Pages - uses: actions/configure-pages@v1 - - name: Generate Docs - uses: fwcd/swift-docc-action@v1 + - name: Checkout + uses: actions/checkout@v3 with: - target: JWSETKit - output: ./public - transform-for-static-hosting: 'true' - disable-indexing: 'true' - hosting-base-path: JWSETKit - - name: Upload artifact - uses: actions/upload-pages-artifact@v1 - with: - path: ./public - - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: macos-13 - needs: docs + fetch-depth: 0 - steps: - - name: Deploy Docs - uses: actions/deploy-pages@v1 + # Build the DocC website using swiftPM. + - name: Build docs with SwiftPM + run: | + swift package --allow-writing-to-directory ./docs \ + generate-documentation --target ${BUILD_TARGET} \ + --output-path ./docs \ + --disable-indexing \ + --transform-for-static-hosting \ + --hosting-base-path JWSETKit + + - name: Commit and push generated documentation + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" + git switch gh-pages + git add ./docs + git commit -a -m "Generated Swift DocC" + git push origin gh-pages + \ No newline at end of file