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

Migrate Demo from AWS Lightsail to GitPages #2034

Merged
merged 14 commits into from
Aug 12, 2024
112 changes: 77 additions & 35 deletions .github/workflows/deploy-demo.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,83 @@
name: Deploy demo
# Builds a Docker image of the demo project, pushes it to
# AWS ECR, and deploys it to AWS Lightsail.
# Simple workflow for deploying static content to GitHub Pages
name: Deploy static content to Pages

on:
workflow_dispatch:
# Runs on pushes targeting the demo branch
push:
branches:
- demo
branches: ["demo"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

env:
PYTHON_VERSION: '3.9'

jobs:
deploy_demo:
# Single deploy job since we're just deploying
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup environment
run: |-
cd demo-project
echo "AWS_ECR_URL=public.ecr.aws/g0x0s3o2/kedro-viz-live-demo" >> $GITHUB_ENV
echo "KEDRO_VIZ_VERSION=$(cat .version)" >> $GITHUB_ENV

- name: Install AWS CLI
run: pip3 install awscli

- name: Build demo container image
run: |-
cd demo-project
echo "kedro_viz==$KEDRO_VIZ_VERSION" >> src/docker_requirements.txt
docker build -t $AWS_ECR_URL:$KEDRO_VIZ_VERSION .
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
docker push $AWS_ECR_URL:$KEDRO_VIZ_VERSION

- name: Create a new lightsail deployment
run: |-
cd demo-project
# run https://docs.aws.amazon.com/cli/latest/reference/lightsail/create-container-service-deployment.html#create-container-service-deployment
aws lightsail create-container-service-deployment --region eu-west-2 --cli-input-json file://./lightsail.json
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Cache python packages for Linux
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ubuntu-latest-python-3.9

- name: Install Kedro and other Python Dependencies
uses: "./.github/actions/install_kedro_and_python_dependencies"

- name: Setup Node.js and Install Dependencies
uses: "./.github/actions/install_node_dependencies"

- name: Build React application
run: |-
node -v
make build

- name: Install Kedro-Viz development package
run: |
pip install -e package
shell: bash
ravi-kumar-pilla marked this conversation as resolved.
Show resolved Hide resolved

- name: Update demo-project build directory with the latest changes
run: |
cd demo-project
if ! (kedro viz build |& tee /dev/stderr | grep -i -q "Success!"); then
exit 1
fi
shell: bash


- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: 'demo-project/build'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cypress/screenshots
cypress/downloads/

# production
build/
/build/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build seems to be in the root similar to lib. Why is this needed ?

Copy link
Contributor Author

@rashidakanchwala rashidakanchwala Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want to ignore the root build but keep the demo/build. build folder is created when you do npm run build and we don't want to accidentally push that to github.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I understand that. Before this change we were doing the same right. The forward slash might not be needed I guess

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when i remove the forward slash, it also ignores the demo/build which we don't want to ignore anymore as it has static graphql files

lib/

# misc
Expand Down
2 changes: 1 addition & 1 deletion demo-project/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ __pycache__/

# Distribution / packaging
.Python
build/

develop-eggs/
dist/
downloads/
Expand Down
12 changes: 12 additions & 0 deletions demo-project/build/api/package-compatibilities
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[
{
"package_name": "fsspec",
"package_version": "2024.6.1",
"is_compatible": true
},
{
"package_name": "kedro-datasets",
"package_version": "4.0.0",
"is_compatible": true
}
]
Loading
Loading