Deploy new pages build #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 new pages build" | |
on: | |
workflow_dispatch: | |
permissions: | |
contents: write | |
concurrency: | |
group: "pages" | |
cancel-in-progress: true | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Clone the dev branch directly | |
- name: Clone dev branch | |
run: | | |
git clone --branch dev https://github.com/${{ github.repository }} dev-branch | |
cd dev-branch | |
# Set up Node.js environment | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
# Install dependencies from dev branch | |
- name: Install dependencies | |
run: | | |
cd dev-branch | |
if [ -f package-lock.json ]; then | |
npm ci | |
else | |
echo "package.json not found in dev branch" | |
exit 1 | |
fi | |
# Build the project | |
- name: Build project | |
run: | | |
cd dev-branch | |
npm run build | |
# Deploy the build output to the 'pages' branch | |
- name: Deploy to Pages Branch | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
# Check out the pages branch or create it | |
git checkout pages || git checkout -b pages | |
# Copy the build output from dev-branch/.app to the root | |
cp -r dev-branch/.app/* ./ | |
# Stage, commit, and push changes | |
git add . | |
git diff --quiet && git diff --staged --quiet || git commit -m "Deploy updated build to pages branch" | |
git push origin pages |