Update deploy.yml #36
This file contains hidden or 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
| name: Build, Test, and Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| build_and_deploy: | |
| runs-on: ubuntu-latest | |
| permissions: # Explicitly set the required permissions for deploying | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run tests | |
| run: cd ./tests && chmod +x run_tests.sh && ./run_tests.sh # Ensure the script has execute permissions and run tests | |
| continue-on-error: false # Skip deployment if tests fail | |
| # Prepare files for GitHub Pages and exclude the _site directory | |
| - name: Prepare files for GitHub Pages | |
| run: | | |
| mkdir -p ./_site | |
| rsync -av --progress ./ ./_site --exclude _site # Use rsync to exclude the _site directory | |
| - name: Upload GitHub Pages artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./_site | |
| - name: Deploy to GitHub Pages | |
| uses: actions/deploy-pages@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} # Ensure GitHub Pages deploy token is set |