Update deploy.yml #28
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: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Run tests | |
| run: chmod +x ./tests/run_tests.sh # Ensure the script has execute permissions | |
| 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 | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| if: success() # Only deploy if build (and tests) succeed | |
| permissions: | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Deploy to GitHub Pages | |
| uses: actions/deploy-pages@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} |