workflows: update deploy on create branch #4
This file contains 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 HTML Pages | |
on: | |
push: | |
branches: | |
- vue | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20.9.0 | |
- name: Install pnpm | |
run: npm install -g pnpm@9.1.4 | |
- name: Install dependencies | |
run: pnpm install --no-frozen-lockfile | |
- name: Build project | |
run: pnpm build | |
- name: Deploy to GitHub Pages | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
echo "Creating temporary directory" | |
mkdir temp-deploy | |
cp -r dist/* temp-deploy/ | |
echo "Fetching all branches" | |
git fetch origin | |
echo "Checking if webpage branch exists" | |
if git show-ref --verify --quiet refs/heads/webpage; then | |
echo "webpage branch exists, checking out" | |
git checkout webpage | |
else | |
echo "webpage branch does not exist, creating new branch" | |
git checkout -b webpage | |
fi | |
echo "Copying build files to webpage branch" | |
cp -r temp-deploy/* . | |
echo "Committing changes" | |
git add . | |
git commit -m "Deploy to HTML Web Pages" | |
echo "Pushing to webpage branch" | |
git push origin webpage --force | |
- name: Check git status | |
run: git status |