From 0a1c6c4bf3e851fe17a6cea7d45e925d8e733861 Mon Sep 17 00:00:00 2001 From: Jirka Borovec <6035284+Borda@users.noreply.github.com> Date: Thu, 21 Mar 2024 18:38:59 +0100 Subject: [PATCH] ci: deploy docs via GCP (#8) --- .github/workflows/docs-build.yml | 53 ++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/.github/workflows/docs-build.yml b/.github/workflows/docs-build.yml index d37e381b40..d17ae79eef 100644 --- a/.github/workflows/docs-build.yml +++ b/.github/workflows/docs-build.yml @@ -22,27 +22,46 @@ jobs: install-tex: true deploy-docs: - # https://github.com/marketplace/actions/deploy-to-github-pages - needs: build-docs - if: github.event_name != 'pull_request' + needs: docs-make + if: github.repository_owner == 'Lightning-AI' && github.event_name == 'push' runs-on: ubuntu-latest + env: + GCP_TARGET: "gs://lightning-docs-thunder" steps: - - name: Checkout 🛎️ - uses: actions/checkout@v4 - with: - # If you're using actions/checkout@v4 you must set persist-credentials to false in most cases for the deployment to work correctly. - persist-credentials: false - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: name: docs-html-${{ github.sha }} path: docs/build/ - - name: Deploy 🚀 - uses: JamesIves/github-pages-deploy-action@v4.5.0 + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@v2 + with: + credentials_json: ${{ secrets.GCS_SA_KEY }} + + - name: Setup gcloud + uses: google-github-actions/setup-gcloud@v2 with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: gh-pages # The branch the action should deploy to. - folder: docs/build/html # The folder the action should deploy. - clean: true # Automatically remove deleted files from the deploy branch - target-folder: docs # If you'd like to push the contents of the deployment folder into a specific directory - single-commit: true # you'd prefer to have a single commit on the deployment branch instead of full history + project_id: ${{ secrets.GCS_PROJECT }} + + # Uploading docs to GCS, so they can be served on lightning.ai + #- name: Upload docs/thunder/stable to GCS 🪣 + # if: startsWith(github.ref, 'refs/heads/release/') + # run: gsutil -m rsync -d -R docs/build/html/ ${GCP_TARGET}/stable + + # Uploading docs to GCS, so they can be served on lightning.ai + - name: Upload docs/thunder/latest to GCS 🪣 + if: github.ref == 'refs/heads/master' + run: gsutil -m rsync -d -R docs/build/html/ ${GCP_TARGET}/latest + + # Uploading docs to GCS, so they can be served on lightning.ai + #- name: Upload docs/thunder/release to GCS 🪣 + # if: startsWith(github.ref, 'refs/tags/') + # run: gsutil -m rsync -d -R docs/build/html/ ${GCP_TARGET}/${{ github.ref_name }} + + # Uploading docs as archive to GCS, so they can be as backup + #- name: Upload docs as archive to GCS 🪣 + # if: startsWith(github.ref, 'refs/tags/') + # working-directory: docs/build + # run: | + # zip ${{ github.ref_name }}.zip -r html/ + # gsutil cp ${{ github.ref_name }}.zip ${GCP_TARGET}