Skip to content

Deploy Website Code to GitHub Pages #397

Deploy Website Code to GitHub Pages

Deploy Website Code to GitHub Pages #397

Workflow file for this run

name: Deploy Website Code to GitHub Pages
on:
workflow_run:
workflows: ["Generate Predictions"] # Name of the workflow to wait for
types:
- completed # Trigger only when the workflow completes
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout prod branch
uses: actions/checkout@v2
with:
ref: prod # Checkout the prod branch
- name: Ensure gh-pages Directory Exists
run: |
mkdir -p gh-pages
- name: List Contents of Website Code
run: ls -R "Website code"
- name: Copy Website Code folder to gh-pages branch
run: |
git config --global user.name 'blake-noske' # Replace with your GitHub username
git config --global user.email 'blake.noske@gmail.com' # Replace with your email
# Switch to the prod branch to access the Website code folder
git checkout prod
# List the contents of the current directory to confirm 'Website code' exists
echo "Current directory contents:"
ls -R .
echo "Contents of 'Website code':"
ls -R "Website code"
# Create a temporary directory to store the copied files
mkdir -p temp_website_code
# Copy the contents of the 'Website code' folder to the temporary directory
cp -r "Website code/"* temp_website_code/
# Switch to the gh-pages branch
git checkout gh-pages || git checkout --orphan gh-pages
# Remove all files (if any) from gh-pages branch
git rm -rf .
# Move the files from the temporary directory into the gh-pages branch
mv temp_website_code/* .
# Clean up the temporary directory
rm -rf temp_website_code
# Add and commit changes
git add .
git commit -m "Update website from Website code folder"
git push origin gh-pages --force