Skip to content

Add staging docs site deploy and update prod deploy #309

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

Merged
merged 24 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
34d0e54
Add new staging docs site deploy action and workflow
nrichers Sep 3, 2024
65614e5
Change to PR branch for testing
nrichers Sep 3, 2024
6daedc4
Change to PR branch for testing, take 2
nrichers Sep 3, 2024
80063bd
Add quarto render steps to staging and prod workflows
nrichers Sep 3, 2024
4d2994f
Minor wording fix
nrichers Sep 3, 2024
013f2ba
Minor wording tweaks
nrichers Sep 3, 2024
1a27b3a
Merge branch 'main' of github.com:validmind/documentation into nriche…
nrichers Sep 3, 2024
f362dc6
Change to prod site for testing
nrichers Sep 3, 2024
2d9f4b2
Fix path issue in aws command, revert to correct branches
nrichers Sep 3, 2024
1ee2e31
Remove some GitHub variables
nrichers Sep 3, 2024
e049b4d
Switch staging deploy to new AWS access keys
nrichers Sep 3, 2024
703946f
Switch to PR branch for testing
nrichers Sep 3, 2024
b3d18c1
Fix duplicate names
nrichers Sep 3, 2024
d5fd81b
Update bucket region info
nrichers Sep 3, 2024
d56e18e
Formatting
nrichers Sep 3, 2024
1aa6a17
Update Cloudfront info for staging and debug paths
nrichers Sep 4, 2024
a3bc0b7
More path debugging
nrichers Sep 4, 2024
22c2822
More path debugging
nrichers Sep 4, 2024
d7d9398
Fix deploy paths & remove debugging info
nrichers Sep 4, 2024
7271caa
Switch back to staging branch
nrichers Sep 4, 2024
c979921
Change to PR branch for testing
nrichers Sep 4, 2024
9fbf32b
Change back to staging branch
nrichers Sep 4, 2024
75adf31
Change to PR branch and docs-demo bucket for testing
nrichers Sep 4, 2024
a6c3f19
Change back to prod branch and prod bucket
nrichers Sep 4, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/ai_explain.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
explain-pr:
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Python
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/delete-pr-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ jobs:
run: aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} && aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} && aws configure set default.region us-east-1

- name: Delete PR preview
run: aws s3 rm s3://${{ vars.S3_BUCKET_DEMO }}/site/pr_previews/${{ github.head_ref }}/ --recursive && aws cloudfront create-invalidation --distribution-id E38AINJY5CYN6P --paths "/*" --no-cli-pager > /dev/null
run: aws s3 rm s3://docs-ci-cd-demo/site/pr_previews/${{ github.head_ref }}/ --recursive && aws cloudfront create-invalidation --distribution-id E38AINJY5CYN6P --paths "/*" --no-cli-pager > /dev/null
30 changes: 25 additions & 5 deletions .github/workflows/deploy-docs-prod.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Deploy our docs site to S3 whenever we push a commit to the main branch

name: Deploy to S3 production bucket
name: Deploy docs site to production

on:
push:
Expand All @@ -12,13 +12,33 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
- name: Check out repository
uses: actions/checkout@v2

- name: Get latest Quarto release URL
id: get-quarto-url
run: |
API_URL="https://api.github.com/repos/quarto-dev/quarto-cli/releases/latest"
DOWNLOAD_URL=$(curl -s $API_URL | jq -r '.assets[] | select(.name | endswith("linux-amd64.deb")).browser_download_url')
echo "DOWNLOAD_URL=$DOWNLOAD_URL" >> $GITHUB_ENV

- name: Download and install Quarto
run: |
wget ${{ env.DOWNLOAD_URL }} -O quarto-latest-linux-amd64.deb
sudo dpkg -i quarto-latest-linux-amd64.deb

- name: Render docs site
run: |
cd site
quarto render &> render_errors.log || {
echo "Quarto render failed immediately";
cat render_errors.log;
exit 1;
}

# Prod bucket is in us-east-1
- name: Configure AWS credentials
run: aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} && aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} && aws configure set default.region us-east-1

- name: Sync to S3
run:
aws s3 sync site/_site s3://${{ vars.S3_BUCKET_PROD }}/site --delete && aws cloudfront create-invalidation --distribution-id E2I9R40IH01NW3 --paths "/*" --no-cli-pager
- name: Deploy docs site
run: aws s3 sync site/_site s3://docs-ci-cd-prod/site --delete && aws cloudfront create-invalidation --distribution-id E2I9R40IH01NW3 --paths "/*" --no-cli-pager
44 changes: 44 additions & 0 deletions .github/workflows/deploy-docs-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Deploy our docs site to S3 whenever we push a commit to the main branch

name: Deploy docs site to staging

on:
push:
branches:
- staging

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Get latest Quarto release URL
id: get-quarto-url
run: |
API_URL="https://api.github.com/repos/quarto-dev/quarto-cli/releases/latest"
DOWNLOAD_URL=$(curl -s $API_URL | jq -r '.assets[] | select(.name | endswith("linux-amd64.deb")).browser_download_url')
echo "DOWNLOAD_URL=$DOWNLOAD_URL" >> $GITHUB_ENV

- name: Download and install Quarto
run: |
wget ${{ env.DOWNLOAD_URL }} -O quarto-latest-linux-amd64.deb
sudo dpkg -i quarto-latest-linux-amd64.deb

- name: Render docs site
run: |
cd site
quarto render &> render_errors.log || {
echo "Quarto render failed immediately";
cat render_errors.log;
exit 1;
}

# Staging bucket is in us-west-2
- name: Configure AWS credentials
run: aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID_STAGING }} && aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGING }} && aws configure set default.region us-west-2

- name: Deploy docs site
run: aws s3 sync site/_site s3://docs-ci-cd-staging/site --delete && aws cloudfront create-invalidation --distribution-id E2FB73KGY63MV6 --paths "/*" --no-cli-pager
2 changes: 1 addition & 1 deletion .github/workflows/release_notes_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
if: github.event.pull_request.draft == false

steps:
- name: Checkout repository
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Python
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/validate-docs-site.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
if: github.event.pull_request.draft == false

steps:
- name: Checkout repository
- name: Check out repository
uses: actions/checkout@v2

- name: Get latest Quarto release URL
Expand All @@ -31,7 +31,7 @@ jobs:

- name: Render site
run: |
cd ./site
cd site
quarto render &> render_errors.log || {
echo "Quarto render failed immediately";
cat render_errors.log;
Expand All @@ -48,11 +48,12 @@ jobs:
echo "No warnings or errors detected during Quarto render"
fi

# Demo bucket is in us-east-1
- name: Configure AWS credentials
run: aws configure set aws_access_key_id ${{ secrets.AWS_ACCESS_KEY_ID }} && aws configure set aws_secret_access_key ${{ secrets.AWS_SECRET_ACCESS_KEY }} && aws configure set default.region us-east-1

- name: Deploy PR preview
run: aws s3 sync site/_site s3://${{ vars.S3_BUCKET_DEMO }}/site/pr_previews/${{ github.head_ref }} --delete && aws cloudfront create-invalidation --distribution-id E38AINJY5CYN6P --paths "/*" --no-cli-pager
run: aws s3 sync site/_site s3://docs-ci-cd-demo/site/pr_previews/${{ github.head_ref }} --delete && aws cloudfront create-invalidation --distribution-id E38AINJY5CYN6P --paths "/*" --no-cli-pager

- name: Post comment with preview URL
uses: actions/github-script@v6
Expand Down
13 changes: 12 additions & 1 deletion site/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DEST_DIR_TESTS := tests
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)

# Define .PHONY target for help section
.PHONY: help clean clone notebooks python-docs docs-site deploy-demo deploy-demo-branch delete-demo-branch deploy-prod release-notes
.PHONY: help clean clone notebooks python-docs docs-site deploy-demo deploy-demo-branch delete-demo-branch deploy-prod deploy-staging release-notes

# Help section
help:
Expand All @@ -21,6 +21,7 @@ help:
@echo " deploy-demo-branch Deploy docs demo site to s3://docs-ci-cd-demo/site/pr_previews/$(GIT_BRANCH)/"
@echo " delete-demo-branch Delete docs demo site in s3://docs-ci-cd-demo/site/pr_previews/$(GIT_BRANCH)/"
@echo " deploy-prod Deploy docs prod site to s3://docs-ci-cd-prod/site/"
@echo " deploy-staging Deploy docs staging site to s3://docs-ci-cd-staging/site/"
@echo " help Display this help message (default target)"
@echo " release-notes Generate release notes from pull requests since latest tag and update _quarto.yml"

Expand Down Expand Up @@ -107,6 +108,16 @@ deploy-prod:
quarto render && aws s3 sync ./_site s3://docs-ci-cd-prod/site/ --delete && aws cloudfront create-invalidation --distribution-id E2I9R40IH01NW3 --paths "/*" --no-cli-pager > /dev/null; \
fi

# Deployment to https://docs.validmind.ai/
# TO DO Fix Cloudfront distribution ID
deploy-staging:
@if [ "`git rev-parse --abbrev-ref HEAD`" != "nrichers/sc-6277/deploy-staging-docs-site-workflow" ]; then \
echo "You're not on the staging branch, no action taken."; \
else \
echo "\nDeploying staging site ..."; \
quarto render && aws s3 sync ./_site s3://docs-ci-cd-staging/site/ --delete && aws cloudfront create-invalidation --distribution-id E2FB73KGY63MV6 --paths "/*" --no-cli-pager > /dev/null; \
fi

# Generate release notes
release-notes:
@python ../release-scripts/generate_release_objects.py
Loading