mirror of
https://github.com/Lapikud/lapikud.github.io.git
synced 2026-08-08 16:29:14 +00:00
changed workflow to github pages artifact
This commit is contained in:
65
.github/workflows/build-deploy.yml
vendored
65
.github/workflows/build-deploy.yml
vendored
@@ -1,32 +1,32 @@
|
|||||||
name: Build and Deploy to Production
|
name: Build and Deploy to GitHub Pages
|
||||||
|
|
||||||
# Configuration
|
|
||||||
env:
|
|
||||||
SOURCE_BRANCH: v2 # Change this to your desired trigger branch
|
|
||||||
PRODUCTION_BRANCH: production # Change this to your desired output branch
|
|
||||||
NODE_VERSION: "24" # Specify Node version for consistency
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- v2 # Update this if you change SOURCE_BRANCH above
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: pages
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-deploy:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
permissions:
|
|
||||||
contents: write # Required to push to the production branch
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout source
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
|
||||||
fetch-depth: 0 # Full history for better git operations
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: ${{ env.NODE_VERSION }}
|
node-version: 24
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -35,24 +35,19 @@ jobs:
|
|||||||
- name: Build project
|
- name: Build project
|
||||||
run: npm run build
|
run: npm run build
|
||||||
|
|
||||||
- name: Prepare for deployment
|
- name: Setup Pages
|
||||||
run: |
|
uses: actions/configure-pages@v5
|
||||||
# Keep only the build output and git metadata
|
|
||||||
find . -mindepth 1 -maxdepth 1 ! -name .git ! -name dist -exec rm -rf {} +
|
|
||||||
# Copy build output to repo root (includes files from public/)
|
|
||||||
cp -a dist/. .
|
|
||||||
rm -rf dist
|
|
||||||
|
|
||||||
- name: Deploy to production branch
|
- name: Upload build artifact
|
||||||
run: |
|
uses: actions/upload-pages-artifact@v3
|
||||||
git config user.name "github-actions[bot]"
|
with:
|
||||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
path: ./dist
|
||||||
git add -A
|
|
||||||
|
deploy:
|
||||||
# Check if there are changes
|
needs: build
|
||||||
if git diff --quiet --cached; then
|
runs-on: ubuntu-latest
|
||||||
echo "No changes to commit"
|
|
||||||
else
|
steps:
|
||||||
git commit -m "Build from ${{ github.sha }}"
|
- name: Deploy to GitHub Pages
|
||||||
git push origin HEAD:${{ env.PRODUCTION_BRANCH }} --force
|
id: deployment
|
||||||
fi
|
uses: actions/deploy-pages@v4
|
||||||
|
|||||||
Reference in New Issue
Block a user