Skip to content

Merging staging into prod #331

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 4 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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
Loading