Skip to content

update docker image to install required libraries #6

update docker image to install required libraries

update docker image to install required libraries #6

Workflow file for this run

name: Render Quarto Files and Deploy to GitHub Pages
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch: # Manual trigger
jobs:
render_quarto:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Build Docker image
run: |
docker build -t demo-quarto-image .
- name: Run Quarto in Docker container
run: |
docker run --rm -v ${{ github.workspace }}:/workspace -w /workspace demo-quarto-image bash -c "
echo 'Creating gallery directory...'
mkdir -p gallery && \
echo 'gallery directory created.'
FOLDERS=(python R)
echo 'Folders to process: ${FOLDERS[@]}'
for FOLDER in \"\${FOLDERS[@]}\"; do
echo 'Searching for .qmd and .ipynb files in $FOLDER...'
find \"\$FOLDER\" \( -name '*.qmd' -o -name '*.ipynb' \) | while read file; do
echo 'Processing file: $file'
target_dir='gallery/$(dirname \"$file\")'
echo 'Creating target directory: $target_dir'
mkdir -p \"\$target_dir\" && echo 'Directory $target_dir created.'
echo 'Attempting to render $file with execution...'
if quarto render \"\$file\" --to html --output-dir \"\$target_dir\"; then
echo 'Successfully rendered $file with execution.'
else
echo 'Failed to render $file with execution. Rendering without execution...'
if quarto render \"\$file\" --to html --no-execute --output-dir \"\$target_dir\"; then
echo 'Successfully rendered $file without execution.'
else
echo 'Rendering failed for $file, even without execution.'
fi
fi
done
done"
- name: Generate Index HTML
run: |
echo "<html><body><h1>Gallery Index</h1><ul>" > gallery/index.html
find gallery -name "*.html" | while read file; do
file_name=$(basename "$file")
echo "<li><a href=\"./$file\">$file_name</a></li>" >> gallery/index.html
done
echo "</ul></body></html>" >> gallery/index.html
- name: Upload HTML output
uses: actions/upload-artifact@v3
with:
name: gallery
path: gallery
- name: Set up Git user
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
- name: Commit and Push to docs branch
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Fetch all branches
git fetch origin
# Check if the docs branch exists, create it if not
if git show-ref --quiet refs/heads/docs; then
git checkout docs
else
git checkout --orphan docs
fi
# Copy the gallery folder to the root of the docs branch
cp -r gallery/* .
# Add, commit, and push changes
git add gallery
git commit -m "Update rendered Quarto files for GitHub Pages (commit: ${{ github.sha }})"
git push origin docs --force