From 940cf67188858c037dea8b088ba3ed5e543d8acd Mon Sep 17 00:00:00 2001 From: Amrit Krishnan Date: Mon, 15 Jul 2024 11:27:23 -0400 Subject: [PATCH 1/5] Fix docs workflow (#659) Co-authored-by: GitHub Actions --- .github/workflows/docs.yml | 53 ++++++++++++-------------------------- 1 file changed, 16 insertions(+), 37 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d1032e125..26aca5ace 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,38 +2,36 @@ name: docs on: pull_request: - branches: - - main + branches: [main] paths: - - .pre-commit-config.yaml - - .github/workflows/docs.yml + - '.pre-commit-config.yaml' + - '.github/workflows/docs.yml' - '**.py' - '**.ipynb' - '**.html' - '**.jinja' - '**.js' - - poetry.lock - - pyproject.toml + - 'poetry.lock' + - 'pyproject.toml' - '**.rst' - '**.md' - - docs/cyclops-webpage + - 'docs/cyclops-webpage/**' types: [opened, synchronize, closed] push: - branches: - - main + branches: [main] paths: - - .pre-commit-config.yaml - - .github/workflows/docs.yml + - '.pre-commit-config.yaml' + - '.github/workflows/docs.yml' - '**.py' - '**.ipynb' - '**.html' - '**.jinja' - '**.js' - - poetry.lock - - pyproject.toml + - 'poetry.lock' + - 'pyproject.toml' - '**.rst' - '**.md' - - docs/cyclops-webpage + - 'docs/cyclops-webpage/**' jobs: check_release: @@ -95,30 +93,11 @@ jobs: yarn install --frozen-lockfile yarn build cp -r ../build/html build/api - - name: Prepare github_pages branch - run: | - git config --global user.name 'GitHub Actions' - git config --global user.email 'actions@github.com' - git fetch origin github_pages:github_pages || git checkout --orphan github_pages - git checkout github_pages - git rm -rf . - git clean -fxd - - name: Copy built files - run: | - cp -R docs/cyclops-webpage/build/* . - if [[ "${{ needs.check_release.outputs.is_release }}" != "true" ]]; then - mkdir -p docs/cyclops-webpage/build/api - git checkout github_pages -- docs/cyclops-webpage/build/api/*.html || true - fi - - name: Commit and push to github_pages - run: | - git add . - git commit -m "Update documentation" || echo "No changes to commit" - git push -f origin github_pages - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v4.0.0 + uses: peaceiris/actions-gh-pages@v4 + if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_branch: github_pages - publish_dir: . + publish_dir: ./docs/cyclops-webpage/build keep_files: ${{ needs.check_release.outputs.is_release != 'true' }} + force_orphan: true From aafdaf66f4efd3d540523e010af725b52dceb275 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 15 Jul 2024 12:17:52 -0400 Subject: [PATCH 2/5] Change to use the old githug_pages branch --- .github/workflows/docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 26aca5ace..c4b193701 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -98,6 +98,7 @@ jobs: if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) with: github_token: ${{ secrets.GITHUB_TOKEN }} + publish_branch: github_pages publish_dir: ./docs/cyclops-webpage/build keep_files: ${{ needs.check_release.outputs.is_release != 'true' }} force_orphan: true From 211b9ce23b6d4f97ec3a4d9f51e52638936603c3 Mon Sep 17 00:00:00 2001 From: Amrit Krishnan Date: Mon, 15 Jul 2024 13:25:54 -0400 Subject: [PATCH 3/5] Change to use the old githug_pages branch (#660) Co-authored-by: GitHub Actions --- .github/workflows/docs.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 26aca5ace..c4b193701 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -98,6 +98,7 @@ jobs: if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) with: github_token: ${{ secrets.GITHUB_TOKEN }} + publish_branch: github_pages publish_dir: ./docs/cyclops-webpage/build keep_files: ${{ needs.check_release.outputs.is_release != 'true' }} force_orphan: true From e56fb88266d8d0861da9bf05871916d997f586cb Mon Sep 17 00:00:00 2001 From: Amrit Krishnan Date: Mon, 15 Jul 2024 15:08:32 -0400 Subject: [PATCH 4/5] Simpler workflow (#662) * Simpler workflow * Small fix * Fix runs-on --------- Co-authored-by: GitHub Actions --- .github/workflows/docs.yml | 68 ++++++++------------------------------ 1 file changed, 14 insertions(+), 54 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c4b193701..d475f7210 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,102 +3,62 @@ name: docs on: pull_request: branches: [main] - paths: - - '.pre-commit-config.yaml' - - '.github/workflows/docs.yml' - - '**.py' - - '**.ipynb' - - '**.html' - - '**.jinja' - - '**.js' - - 'poetry.lock' - - 'pyproject.toml' - - '**.rst' - - '**.md' - - 'docs/cyclops-webpage/**' - types: [opened, synchronize, closed] + types: [opened, synchronize, labeled, unlabeled, closed] push: branches: [main] - paths: - - '.pre-commit-config.yaml' - - '.github/workflows/docs.yml' - - '**.py' - - '**.ipynb' - - '**.html' - - '**.jinja' - - '**.js' - - 'poetry.lock' - - 'pyproject.toml' - - '**.rst' - - '**.md' - - 'docs/cyclops-webpage/**' jobs: - check_release: - runs-on: ubuntu-latest - outputs: - is_release: ${{ steps.check_release.outputs.is_release }} - steps: - - name: Check if release PR - id: check_release - if: github.event_name == 'pull_request' - run: | - if [[ ${{ contains(github.event.pull_request.labels.*.name, 'release') }} == 'true' ]]; then - echo "is_release=true" >> $GITHUB_OUTPUT - else - echo "is_release=false" >> $GITHUB_OUTPUT - fi - build: - needs: check_release - if: github.event_name == 'push' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'synchronize' || (github.event.action == 'closed' && github.event.pull_request.merged == true))) - runs-on: ${{ needs.check_release.outputs.is_release == 'true' && fromJSON('["self-hosted", "db", "cyclops"]') || 'ubuntu-latest' }} + runs-on: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') && fromJSON('["self-hosted", "db", "cyclops"]') || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4.1.7 with: submodules: 'true' fetch-depth: 0 + - name: Install poetry run: python3 -m pip install --upgrade pip && python3 -m pip install poetry + - uses: actions/setup-python@v5.1.0 with: python-version: '3.10' cache: 'poetry' - - name: Install dependencies, build docs + + - name: Install dependencies run: | - python3 -m pip install --upgrade pip && python3 -m pip install poetry poetry env use '3.10' - source $(poetry env info --path)/bin/activate poetry install --with docs,test --all-extras + - name: Build docs + run: | + source $(poetry env info --path)/bin/activate cd docs rm -rf source/reference/api/_autosummary - if [[ "${{ needs.check_release.outputs.is_release }}" == "true" ]]; then + if [[ "${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') }}" == "true" ]]; then make html-with-notebooks else - # Install Pandoc - PANDOC_VERSION="2.19" - curl -sLo- "https://github.com/jgm/pandoc/releases/download/${PANDOC_VERSION}/pandoc-${PANDOC_VERSION}-linux-amd64.tar.gz" | tar xzf - --strip-components 2 -C /usr/local/bin --exclude="share" make html fi + - name: Set up Node.js uses: actions/setup-node@v4.0.2 with: node-version: 18 cache: yarn cache-dependency-path: '**/yarn.lock' + - name: Build webpage run: | cd docs/cyclops-webpage yarn install --frozen-lockfile yarn build cp -r ../build/html build/api + - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v4 - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true) + if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') with: github_token: ${{ secrets.GITHUB_TOKEN }} publish_branch: github_pages publish_dir: ./docs/cyclops-webpage/build - keep_files: ${{ needs.check_release.outputs.is_release != 'true' }} force_orphan: true From c24ea8fb90a3d25e0c30e45ab0c79f49e0350402 Mon Sep 17 00:00:00 2001 From: Amrit Krishnan Date: Tue, 16 Jul 2024 08:53:09 -0400 Subject: [PATCH 5/5] Fix docs (#663) Co-authored-by: GitHub Actions --- .github/workflows/docs.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d475f7210..b843589cc 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -3,13 +3,11 @@ name: docs on: pull_request: branches: [main] - types: [opened, synchronize, labeled, unlabeled, closed] - push: - branches: [main] + types: [opened, synchronize, closed] jobs: build: - runs-on: ${{ github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release') && fromJSON('["self-hosted", "db", "cyclops"]') || 'ubuntu-latest' }} + runs-on: ${{ (github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')) && fromJSON('["self-hosted", "db", "cyclops"]') || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4.1.7 with: @@ -54,6 +52,9 @@ jobs: yarn build cp -r ../build/html build/api + - name: Create .nojekyll file + run: touch ./docs/cyclops-webpage/build/.nojekyll + - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v4 if: github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'release')