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

adds an action to preview docs #886

Merged
merged 20 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
Empty file removed .github/workflows/build-docs.yml
Empty file.
99 changes: 99 additions & 0 deletions .github/workflows/preview-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# deploys a preview version of the frontend including example changes
name: Preview Docs
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
build-preview:
name: Build and deploy preview
runs-on: ubuntu-20.04
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_MODAL_LABS_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_MODAL_LABS_TOKEN_SECRET }}
MODAL_ENVIRONMENT: examples

steps:
- name: Checkout modal repo
uses: actions/checkout@v3
with:
repository: modal-labs/modal
token: ${{ secrets.GH_PAT }}
fetch-depth: 1
path: modal
persist-credentials: false

- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install base packages
shell: bash
run: |
pip install uv
uv pip install --system setuptools wheel

- name: Install modal development packages
run: |
uv pip install --system -r modal/requirements.dev.txt

- name: Checkout client repo
uses: actions/checkout@v3
with:
repository: modal-labs/modal-client
token: ${{ secrets.GH_PAT }}
path: client
fetch-depth: 1
persist-credentials: false

- name: Install client repo
run: |
uv pip install --system -e client

- name: Install node
uses: actions/setup-node@v4
with:
node-version: 18

- name: Install node packages
run: npm ci --include=dev
working-directory: modal/frontend

- name: Compile protos
run: |
cd client
inv protoc type-stubs
cd ../modal
inv protoc

- name: Checkout examples repo
uses: actions/checkout@v3
with:
fetch-depth: 1
path: modal/examples

- name: Build and deploy preview
id: deploy_preview
working-directory: modal
run: |
export DEPLOYMENT_ID=${GITHUB_SHA::7}
inv frontend-preview --skip-update --deployment-id $DEPLOYMENT_ID | tee output.txt
DEPLOYMENT_URL=$(cat output.txt | grep "$DEPLOYMENT_ID" | grep "modal.run" | tail -n 1)
echo "DEPLOYMENT_URL=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT

- name: Post a comment with the preview URL
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_PAT }}
script: |
const deploymentUrl = `${{ steps.deploy_preview.outputs.DEPLOYMENT_URL }}`;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🚀 The docs preview is ready! Check it out here: ${deploymentUrl}`
});
Loading