Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manual Documentation Preview Action #84

Merged
merged 5 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/cleanup-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Cleanup PR Preview

on:
pull_request:
types: [closed]

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.GH_PAGES_DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts

- name: Delete All Previews
run: |
git clone --single-branch --branch gh-pages git@github.com:MHKiT-Software/MHKiT.git gh-pages
cd gh-pages
rm -rf pr-previews/
git config user.name "GitHub Actions Bot"
git config user.email "<>"
git add -A
git commit -m "Remove all previews after merging PR #${{ github.event.pull_request.number }}" || echo "No cleanup needed"
git push
59 changes: 59 additions & 0 deletions .github/workflows/manual-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Manual Deploy PR Preview

on:
workflow_dispatch:
inputs:
ref:
description: 'Branch of the PR'
required: true
repository:
description: 'Fork repository'
required: true
pr_number:
description: 'Pull Request Number'
required: true

jobs:
deploy_preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
repository: ${{ github.event.inputs.repository }}
submodules: recursive
fetch-depth: 0

- name: Setup Conda Environment
uses: conda-incubator/setup-miniconda@v2
with:
activate-environment: mhkit-docs
environment-file: environment.yml
auto-activate-base: false

- name: Setup SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.GH_PAGES_DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan github.com >> ~/.ssh/known_hosts

- name: Build Documentation
shell: bash -l {0}
run: |
cd docs
rm -rf _build/*
cp -r ../MHKiT-Python/examples/* source/
sphinx-build -b html source _build/html
cp ../MHKiT-MATLAB/examples/*.html ./_build/html/mhkit-matlab
touch _build/html/.nojekyll

- name: Deploy PR Preview
uses: peaceiris/actions-gh-pages@v3
with:
deploy_key: ${{ secrets.GH_PAGES_DEPLOY_KEY }}
publish_dir: ./docs/_build/html
destination_dir: pr-previews/${{ github.event.inputs.pr_number }}
external_repository: MHKiT-Software/MHKiT
keep_files: true
enable_jekyll: false
Loading