Add build workflow #6
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
| # .github/workflows/build.yml | |
| name: Build and Deploy | |
| on: | |
| push: | |
| branches: | |
| - vite | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout vite branch | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 20.19.0 | |
| - name: Install dependencies | |
| run: yarn install --frozen-lockfile | |
| - name: Build project | |
| run: yarn run build | |
| - name: Deploy dist to build branch | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git fetch origin build:build || git branch build | |
| git checkout build | |
| find . -mindepth 1 -not -name ".git" -exec rm -rf {} + | |
| cp -r ../dist/* . | |
| git add . | |
| git commit -m "Deploy build from ${GITHUB_SHA}" || echo "No changes to commit" | |
| git push origin build |