diff --git a/.github/workflows/sync-to-readthedocs-repo.yaml b/.github/workflows/sync-to-readthedocs-repo.yaml new file mode 100644 index 00000000..3d08d5ac --- /dev/null +++ b/.github/workflows/sync-to-readthedocs-repo.yaml @@ -0,0 +1,72 @@ +name: "sync-to-readthedocs-repo" + +on: + workflow_dispatch: + push: + branches: + - main + - latest + - develop + - 'pre/*' + - 'demo/test/*' + tags: + - 'v*' + - 'demo/*' + +jobs: + extract_branch_or_tag: + outputs: + ref_name: ${{ steps.extract.outputs.ref_name }} + runs-on: ubuntu-latest + steps: + - id: extract + name: Extract branch or tag name + shell: bash + run: | + REF_NAME="${GITHUB_REF#refs/*/}" + echo "::set-output name=ref_name::$REF_NAME" + echo "Extracted ref: $REF_NAME" + + build-and-deploy: + permissions: + contents: write + needs: extract_branch_or_tag + runs-on: ubuntu-latest + steps: + # Conditional Checkout for Branch + - name: Checkout Branch if branch-triggered-sync + if: contains(github.ref, 'refs/heads/') + uses: actions/checkout@v3 + with: + submodules: true + token: ${{ secrets.GH_PAT }} + ref: ${{ needs.extract_branch_or_tag.outputs.ref_name }} + + - name: Push corresponding reference to mirror repo if a branch + if: contains(github.ref, 'refs/heads/') + run: | + git fetch --unshallow origin ${{ needs.extract_branch_or_tag.outputs.ref_name }} + git pull origin ${{ needs.extract_branch_or_tag.outputs.ref_name }} + git remote add mirror https://github.com/flexcompute-readthedocs/tidy3d-notebooks-docs.git + git push mirror ${{ needs.extract_branch_or_tag.outputs.ref_name }} --force # overwrites always + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + + # Conditional Checkout for Tag + - name: Checkout Tag if tag-triggered-sync + if: contains(github.ref, 'refs/tags/') + uses: actions/checkout@v3 + with: + submodules: true + token: ${{ secrets.GH_PAT }} + fetch-depth: 0 + ref: ${{ needs.extract_branch_or_tag.outputs.ref_name }} + fetch-tags: true + + - name: Push corresponding reference to mirror repo if a tag + if: contains(github.ref, 'refs/tags/') + run: | + git remote add mirror https://github.com/flexcompute-readthedocs/tidy3d-notebooks-docs.git + git push mirror ${{ needs.extract_branch_or_tag.outputs.ref_name }} --force # overwrites always + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} diff --git a/.readthedocs.yaml b/.readthedocs.yaml index 283feb12..5f7ec6be 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -1,25 +1,16 @@ version: 2 - -submodules: - include: - - tidy3d - recursive: true - build: - os: "ubuntu-20.04" + os: "ubuntu-22.04" tools: - python: "3.10" + python: "3.11" sphinx: fail_on_warning: false - configuration: docs/source/conf.py + configuration: docs/conf.py python: # Install our python package before building the docs install: - - method: pip - path: . - - requirements: docs/requirements.txt - - requirements: tidy3d/requirements.txt + - requirements: requirements.txt formats: [] diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 00000000..016e2e91 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,4 @@ +from ...conf import * + +extensions = extensions +project = "Tidy3D Examples" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 00000000..8f26be1b --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +tidy3d[dev] \ No newline at end of file