Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 30 additions & 8 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,22 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20' # Use Node 20 for better native dependency support
cache: 'npm'

- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Install native dependencies explicitly
- name: Handle native dependencies
run: |
npm install @parcel/watcher --legacy-peer-deps
npm rebuild @parcel/watcher
# Try to install @parcel/watcher, but don't fail if it doesn't work
npm install @parcel/watcher --legacy-peer-deps || echo "Warning: @parcel/watcher installation failed, continuing..."
# If installation succeeded, try to rebuild
if npm list @parcel/watcher > /dev/null 2>&1; then
npm rebuild @parcel/watcher || echo "Warning: @parcel/watcher rebuild failed, continuing..."
fi
# Alternative: try to install platform-specific version
npm install @parcel/watcher-linux-x64-glibc --legacy-peer-deps || echo "Warning: Linux-specific watcher installation failed, continuing..."

- name: Clean Gatsby cache
run: npx gatsby clean
Expand All @@ -50,6 +56,11 @@ jobs:
export GATSBY_DISABLE_FILE_WATCHER=true
export GATSBY_DISABLE_WATCHER=true
export NODE_ENV=production
# Set additional environment variables to avoid watcher issues
export GATSBY_EXPERIMENTAL_DEV_SSR=false
export GATSBY_EXPERIMENTAL_FAST_DEV=false
# Try to disable any remaining watcher functionality
export GATSBY_DISABLE_ESLINT_PLUGIN=true
npm run build
env:
GATSBY_GA_MEASUREMENT_ID: ${{ secrets.GATSBY_GA_MEASUREMENT_ID }}
Expand All @@ -69,16 +80,22 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18' # Use Node 18 for better compatibility
node-version: '20' # Use Node 20 for better native dependency support
cache: 'npm'

- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Install native dependencies explicitly
- name: Handle native dependencies
run: |
npm install @parcel/watcher --legacy-peer-deps
npm rebuild @parcel/watcher
# Try to install @parcel/watcher, but don't fail if it doesn't work
npm install @parcel/watcher --legacy-peer-deps || echo "Warning: @parcel/watcher installation failed, continuing..."
# If installation succeeded, try to rebuild
if npm list @parcel/watcher > /dev/null 2>&1; then
npm rebuild @parcel/watcher || echo "Warning: @parcel/watcher rebuild failed, continuing..."
fi
# Alternative: try to install platform-specific version
npm install @parcel/watcher-linux-x64-glibc --legacy-peer-deps || echo "Warning: Linux-specific watcher installation failed, continuing..."

- name: Clean Gatsby cache
run: npx gatsby clean
Expand All @@ -88,6 +105,11 @@ jobs:
export GATSBY_DISABLE_FILE_WATCHER=true
export GATSBY_DISABLE_WATCHER=true
export NODE_ENV=production
# Set additional environment variables to avoid watcher issues
export GATSBY_EXPERIMENTAL_DEV_SSR=false
export GATSBY_EXPERIMENTAL_FAST_DEV=false
# Try to disable any remaining watcher functionality
export GATSBY_DISABLE_ESLINT_PLUGIN=true
npm run build
env:
GATSBY_GA_MEASUREMENT_ID: ${{ secrets.GATSBY_GA_MEASUREMENT_ID }}
Expand Down
111 changes: 105 additions & 6 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
name: Pull Request Build Check
name: Pull Request Build Check & Preview

on:
pull_request:
branches: [ production, main, master ]

# Add permissions for GitHub Pages and PR commenting
permissions:
contents: read
pages: write
id-token: write
pull-requests: write # Add permission to comment on PRs
issues: write # Add permission to comment on issues

jobs:
build-check:
runs-on: ubuntu-latest
Expand All @@ -15,16 +23,22 @@ jobs:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
node-version: '20' # Use Node 20 for better native dependency support
cache: 'npm'

- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Install native dependencies explicitly
- name: Handle native dependencies
run: |
npm install @parcel/watcher --legacy-peer-deps
npm rebuild @parcel/watcher
# Try to install @parcel/watcher, but don't fail if it doesn't work
npm install @parcel/watcher --legacy-peer-deps || echo "Warning: @parcel/watcher installation failed, continuing..."
# If installation succeeded, try to rebuild
if npm list @parcel/watcher > /dev/null 2>&1; then
npm rebuild @parcel/watcher || echo "Warning: @parcel/watcher rebuild failed, continuing..."
fi
# Alternative: try to install platform-specific version
npm install @parcel/watcher-linux-x64-glibc --legacy-peer-deps || echo "Warning: Linux-specific watcher installation failed, continuing..."

- name: Clean Gatsby cache
run: npx gatsby clean
Expand All @@ -34,6 +48,11 @@ jobs:
export GATSBY_DISABLE_FILE_WATCHER=true
export GATSBY_DISABLE_WATCHER=true
export NODE_ENV=production
# Set additional environment variables to avoid watcher issues
export GATSBY_EXPERIMENTAL_DEV_SSR=false
export GATSBY_EXPERIMENTAL_FAST_DEV=false
# Try to disable any remaining watcher functionality
export GATSBY_DISABLE_ESLINT_PLUGIN=true
npm run build
env:
GATSBY_GA_MEASUREMENT_ID: ${{ secrets.GATSBY_GA_MEASUREMENT_ID }}
Expand All @@ -42,4 +61,84 @@ jobs:
run: |
echo "✅ Build completed successfully!"
echo "📁 Build output size: $(du -sh public | cut -f1)"
echo "📄 Number of pages built: $(find public -name "*.html" | wc -l)"
echo "📄 Number of pages built: $(find public -name "*.html" | wc -l)"

preview-deploy:
runs-on: ubuntu-latest
needs: build-check
if: github.event_name == 'pull_request'

steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
# Ensure we have access to the PR context
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20' # Use Node 20 for better native dependency support
cache: 'npm'

- name: Install dependencies
run: npm install --legacy-peer-deps

- name: Handle native dependencies
run: |
# Try to install @parcel/watcher, but don't fail if it doesn't work
npm install @parcel/watcher --legacy-peer-deps || echo "Warning: @parcel/watcher installation failed, continuing..."
# If installation succeeded, try to rebuild
if npm list @parcel/watcher > /dev/null 2>&1; then
npm rebuild @parcel/watcher || echo "Warning: @parcel/watcher rebuild failed, continuing..."
fi
# Alternative: try to install platform-specific version
npm install @parcel/watcher-linux-x64-glibc --legacy-peer-deps || echo "Warning: Linux-specific watcher installation failed, continuing..."

- name: Clean Gatsby cache
run: npx gatsby clean

- name: Build website for preview
run: |
export GATSBY_DISABLE_FILE_WATCHER=true
export GATSBY_DISABLE_WATCHER=true
export NODE_ENV=production
# Set additional environment variables to avoid watcher issues
export GATSBY_EXPERIMENTAL_DEV_SSR=false
export GATSBY_EXPERIMENTAL_FAST_DEV=false
# Try to disable any remaining watcher functionality
export GATSBY_DISABLE_ESLINT_PLUGIN=true
npm run build
env:
GATSBY_GA_MEASUREMENT_ID: ${{ secrets.GATSBY_GA_MEASUREMENT_ID }}

- name: Deploy to preview branch
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
destination_dir: preview/pr-${{ github.event.number }}

- name: Comment preview URL
uses: actions/github-script@v7
with:
# Ensure we have the right permissions
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
const previewUrl = `https://${context.repo.owner}.github.io/${context.repo.repo}/preview/pr-${context.issue.number}/`;
console.log(`Attempting to comment with preview URL: ${previewUrl}`);

await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `🎉 **Preview Deployment Ready!**\n\nYour changes are now available for preview at:\n🔗 **${previewUrl}**\n\nThis preview will be automatically cleaned up when the PR is closed or merged.`
});

console.log('✅ Comment added successfully!');
} catch (error) {
console.error('❌ Failed to add comment:', error.message);
// Don't fail the workflow if commenting fails
console.log('Continuing with deployment...');
}
Loading