testing actions #34
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 # Run tests and fail the job if they fail | |
| # Prepare files for GitHub Pages and exclude the _site directory | |
| - name: Prepare files for GitHub Pages | |
| if: success() # This ensures the step only runs if the previous steps (tests) were successful | |
| run: | | |
| mkdir -p ./_site | |
| rsync -av --progress ./ ./_site --exclude _site # Use rsync to exclude the _site directory | |
| - name: Upload GitHub Pages artifact | |
| if: success() # This ensures the step only runs if the previous steps (tests) were successful | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: ./_site | |
| - name: Deploy to GitHub Pages | |
| if: success() # This ensures the step only runs if the previous steps (tests) were successful | |
| uses: actions/deploy-pages@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} # Ensure GitHub Pages deploy token is set |