diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 22ce099..194d1a7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -32,9 +32,27 @@ jobs: - name: Build the project run: npm run build - # Step 6: Deploy the built files to GitHub Pages - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v3 - with: - personal_token: ${{ secrets.GITHUB_TOKEN }} # Use personal_token for deployment - publish_dir: ./build + # Step 6: Checkout gh-pages branch + - name: Checkout gh-pages branch + run: | + git fetch + git checkout gh-pages + + # Step 7: Copy build files to the gh-pages branch + - name: Copy Build Files + run: | + rsync -av --delete ./build/ ./ # Copy build files into root directory + + # Step 8: Copy .github/workflows back to gh-pages + - name: Restore Workflows Directory + run: | + git checkout main -- .github/workflows + + # Step 9: Commit and Push changes to gh-pages branch + - name: Commit changes + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Update GitHub Pages with new build and restore workflows [skip ci]" || echo "No changes to commit" + git push origin gh-pages