diff --git a/.github/workflows/preview-documentation.yml b/.github/workflows/preview-documentation.yml new file mode 100644 index 000000000..9bc3297fd --- /dev/null +++ b/.github/workflows/preview-documentation.yml @@ -0,0 +1,39 @@ +name: Preview Documentation + +on: + pull_request: + types: [opened, synchronize] + +env: + PR_NUMBER: ${{ github.event.pull_request.number }} + GHP_URL: 'https://structuralequationmodels.github.io/StructuralEquationModels.jl/' + +jobs: + build: + if: startsWith(github.head_ref, 'documentation/') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: julia-actions/setup-julia@latest + with: + version: '1.6' + - name: Install dependencies + run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' + - name: Build and deploy + id: deploy + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # If authenticating with GitHub Actions token + DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }} # If authenticating with SSH deploy key + run: julia --project=docs/ docs/make.jl push_preview=true + + - uses: actions/github-script@v5 + if: steps.deploy.outcome == 'success' + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: 'Docs can be previewed here: ${{ env.GHP_URL }}previews/PR${{ env.PR_NUMBER }}' + }) \ No newline at end of file diff --git a/docs/make.jl b/docs/make.jl index 56d46d6ee..d26e4532b 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -72,5 +72,6 @@ makedocs( deploydocs( repo = "github.com/StructuralEquationModels/StructuralEquationModels.jl", - devbranch = "devel" -) \ No newline at end of file + devbranch = "devel", + push_preview = "push_preview=true" ∈ ARGS +)