main html file created in the output #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Step 1: Checkout the code from the main branch | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
# Step 2: Set up Rust | |
- name: Set up Rust | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
profile: minimal | |
override: true | |
# Step 3: Run the Rust program to generate files in the 'output' folder | |
- name: Run Rust program | |
run: cargo run --release | |
# Step 4: Switch to 'gh-pages' branch and clean old content | |
- name: Deploy to GitHub Pages | |
run: | | |
# Configure git | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
# Restart gh-pages branch | |
git branch -D gh-pages || echo "branch gh-pages does not exist" | |
git checkout --orphan gh-pages | |
# Remove all existing files from the branch | |
git rm -rf . | |
# Copy the generated output files into the root directory | |
cp -r output/* . | |
# Remove extra files | |
rm -r output | |
rm -r target | |
# Add and commit the changes | |
git add . | |
git commit -m "Deploy generated files to GitHub Pages" | |
# Push the changes to 'gh-pages' (force to replace old content) | |
git push --force "https://${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git" gh-pages |