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: Deploy to GitHub Pages | |
| on: | |
| push: | |
| branches: [ main ] | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-and-deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Git checkout | |
| uses: actions/checkout@v2 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Use Node 12.x | |
| uses: actions/setup-node@v1 | |
| with: | |
| node-version: 12.x | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Build | |
| run: npm run build | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| - name: Prepare Deployment | |
| run: | | |
| # Create a new directory for deployment | |
| mkdir -p deploy | |
| # Copy only the necessary files | |
| cp -r index.html dist deploy/ | |
| # Create .nojekyll to bypass Jekyll processing | |
| touch deploy/.nojekyll | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "GitHub Actions Bot" | |
| git config --global user.email "actions@github.com" | |
| - name: Force Push to gh-pages | |
| run: | | |
| git fetch origin gh-pages | |
| git checkout gh-pages | |
| git pull origin gh-pages | |
| git add . | |
| git commit -m "Sync with main branch" | |
| git push origin gh-pages --force | |
| - name: Deploy to GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| folder: deploy | |
| branch: gh-pages | |
| clean: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| commit-message: "Deploy from main branch" | |