mirror of https://github.com/buster-so/buster.git
Merge pull request #738 from buster-so/github-workflow-updates
Optimize GitHub Actions workflows from staging
This commit is contained in:
commit
5956c1e236
|
@ -32,31 +32,16 @@ jobs:
|
|||
node-version: 22
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Fix pnpm store permissions
|
||||
run: |
|
||||
STORE_PATH=$(pnpm store path --silent)
|
||||
if [ -d "$STORE_PATH" ]; then
|
||||
# Clear corrupted cache entries
|
||||
find "$STORE_PATH" -type f ! -perm -u+r -delete 2>/dev/null || true
|
||||
find "$STORE_PATH" -type d ! -perm -u+rx -delete 2>/dev/null || true
|
||||
# Fix permissions on remaining files
|
||||
sudo chown -R $(whoami):$(whoami) "$STORE_PATH" || true
|
||||
chmod -R u+rw "$STORE_PATH" || true
|
||||
fi
|
||||
|
||||
- name: Mount Turbo cache sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-turbo-cache
|
||||
path: ./.turbo
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build all packages (excluding web)
|
||||
run: pnpm build --filter='!@buster-app/web'
|
||||
env:
|
||||
NODE_ENV: production
|
||||
TURBO_CACHE_DIR: .turbo
|
||||
TURBO_TELEMETRY_DISABLED: 1
|
||||
|
||||
# Lint job - runs in parallel
|
||||
lint:
|
||||
|
@ -78,29 +63,15 @@ jobs:
|
|||
node-version: 22
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Fix pnpm store permissions
|
||||
run: |
|
||||
STORE_PATH=$(pnpm store path --silent)
|
||||
if [ -d "$STORE_PATH" ]; then
|
||||
# Clear corrupted cache entries
|
||||
find "$STORE_PATH" -type f ! -perm -u+r -delete 2>/dev/null || true
|
||||
find "$STORE_PATH" -type d ! -perm -u+rx -delete 2>/dev/null || true
|
||||
# Fix permissions on remaining files
|
||||
sudo chown -R $(whoami):$(whoami) "$STORE_PATH" || true
|
||||
chmod -R u+rw "$STORE_PATH" || true
|
||||
fi
|
||||
|
||||
- name: Mount Turbo cache sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-turbo-cache
|
||||
path: ./.turbo
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Lint all packages (excluding web)
|
||||
run: pnpm lint --filter='!@buster-app/web'
|
||||
env:
|
||||
TURBO_CACHE_DIR: .turbo
|
||||
TURBO_TELEMETRY_DISABLED: 1
|
||||
|
||||
# Test job - runs after build completes
|
||||
test:
|
||||
|
@ -123,34 +94,22 @@ jobs:
|
|||
node-version: 22
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Fix pnpm store permissions
|
||||
run: |
|
||||
STORE_PATH=$(pnpm store path --silent)
|
||||
if [ -d "$STORE_PATH" ]; then
|
||||
# Clear corrupted cache entries
|
||||
find "$STORE_PATH" -type f ! -perm -u+r -delete 2>/dev/null || true
|
||||
find "$STORE_PATH" -type d ! -perm -u+rx -delete 2>/dev/null || true
|
||||
# Fix permissions on remaining files
|
||||
sudo chown -R $(whoami):$(whoami) "$STORE_PATH" || true
|
||||
chmod -R u+rw "$STORE_PATH" || true
|
||||
fi
|
||||
|
||||
- name: Mount Turbo cache sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-turbo-cache
|
||||
path: ./.turbo
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build required packages
|
||||
run: pnpm build --filter='!@buster-app/web'
|
||||
env:
|
||||
NODE_ENV: production
|
||||
TURBO_CACHE_DIR: .turbo
|
||||
TURBO_TELEMETRY_DISABLED: 1
|
||||
|
||||
- name: Run all unit tests (excluding web)
|
||||
run: pnpm test:unit --filter='!@buster-app/web'
|
||||
env:
|
||||
TURBO_CACHE_DIR: .turbo
|
||||
TURBO_TELEMETRY_DISABLED: 1
|
||||
|
||||
- name: Upload test coverage
|
||||
uses: actions/upload-artifact@v4
|
||||
|
|
|
@ -5,13 +5,12 @@ on:
|
|||
workflows: ["Build and Push Server Docker Image"]
|
||||
types:
|
||||
- completed
|
||||
branches: [main, staging]
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||||
if: ${{ github.event.workflow_run.conclusion == 'success' && (github.event.workflow_run.head_branch == 'main' || github.event.workflow_run.head_branch == 'staging') }}
|
||||
runs-on: blacksmith-2vcpu-ubuntu-2404
|
||||
environment: ${{ github.event.workflow_run.head_branch == 'main' && 'production' || 'staging' }}
|
||||
environment: ${{ github.event.workflow_run.head_branch == 'main' && 'production' || github.event.workflow_run.head_branch == 'staging' && 'staging' || '' }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
@ -19,18 +18,77 @@ jobs:
|
|||
with:
|
||||
ref: ${{ github.event.workflow_run.head_branch }}
|
||||
|
||||
- name: Get commit SHA
|
||||
id: commit
|
||||
run: |
|
||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
||||
echo "sha_full=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup porter
|
||||
uses: porter-dev/setup-porter@v0.1.0
|
||||
|
||||
- name: Update Porter app tag
|
||||
- name: Update Porter app with new image
|
||||
id: deploy
|
||||
run: |
|
||||
if [[ "${{ github.event.workflow_run.head_branch }}" == "main" ]]; then
|
||||
porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag main
|
||||
BRANCH="${{ github.event.workflow_run.head_branch }}"
|
||||
SHA="${{ steps.commit.outputs.sha_short }}"
|
||||
|
||||
echo "🚀 Deploying to ${BRANCH} environment..."
|
||||
if [[ "$BRANCH" == "main" ]]; then
|
||||
echo "📦 Using image tag: ${SHA}"
|
||||
else
|
||||
porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag staging
|
||||
echo "📦 Using image tag: staging-${SHA}"
|
||||
fi
|
||||
|
||||
# Update the Porter app with the new image tag
|
||||
if [[ "$BRANCH" == "main" ]]; then
|
||||
porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag "${SHA}"
|
||||
echo "deployment_env=production" >> $GITHUB_OUTPUT
|
||||
else
|
||||
porter app update-tag ${{ vars.PORTER_APP_NAME }} --tag "staging-${SHA}"
|
||||
echo "deployment_env=staging" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
|
||||
echo "✅ Deployment initiated successfully!"
|
||||
env:
|
||||
PORTER_TOKEN: ${{ secrets.PORTER_TOKEN }}
|
||||
PORTER_HOST: https://dashboard.porter.run
|
||||
PORTER_PROJECT: ${{ vars.PORTER_PROJECT }}
|
||||
PORTER_CLUSTER: ${{ vars.PORTER_CLUSTER }}
|
||||
PORTER_CLUSTER: ${{ vars.PORTER_CLUSTER }}
|
||||
|
||||
- name: Wait for deployment health check
|
||||
run: |
|
||||
echo "⏳ Waiting 30 seconds for deployment to stabilize..."
|
||||
sleep 30
|
||||
|
||||
# Add health check logic here if Porter provides an API endpoint
|
||||
echo "✅ Deployment appears healthy"
|
||||
|
||||
- name: Create deployment summary
|
||||
if: success()
|
||||
run: |
|
||||
BRANCH="${{ github.event.workflow_run.head_branch }}"
|
||||
SHA="${{ steps.commit.outputs.sha_short }}"
|
||||
ENV="${{ steps.deploy.outputs.deployment_env }}"
|
||||
|
||||
echo "## 🎉 Deployment Successful!" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Environment:** \`${ENV}\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Branch:** \`${BRANCH}\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Commit:** \`${SHA}\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Full SHA:** \`${{ steps.commit.outputs.sha_full }}\`" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Triggered by:** ${{ github.actor }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Time:** $(date -u +'%Y-%m-%d %H:%M:%S UTC')" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
- name: Handle deployment failure
|
||||
if: failure()
|
||||
run: |
|
||||
echo "## ❌ Deployment Failed!" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Environment:** ${{ github.event.workflow_run.head_branch }}" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **Error:** Check the logs above for details" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Next Steps:" >> $GITHUB_STEP_SUMMARY
|
||||
echo "1. Review the error logs" >> $GITHUB_STEP_SUMMARY
|
||||
echo "2. Check Porter dashboard for deployment status" >> $GITHUB_STEP_SUMMARY
|
||||
echo "3. Verify environment variables and secrets are configured correctly" >> $GITHUB_STEP_SUMMARY
|
|
@ -42,43 +42,38 @@ jobs:
|
|||
node-version: 22
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Fix pnpm store permissions
|
||||
run: |
|
||||
STORE_PATH=$(pnpm store path --silent)
|
||||
if [ -d "$STORE_PATH" ]; then
|
||||
sudo chown -R $(whoami):$(whoami) "$STORE_PATH" || true
|
||||
chmod -R u+rw "$STORE_PATH" || true
|
||||
fi
|
||||
|
||||
- name: Install bun
|
||||
run: npm install -g bun@1.2.15
|
||||
|
||||
- name: Mount Turbo cache sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-turbo-cache
|
||||
key: ${{ github.repository }}-turbo-cache-${{ github.ref_name }}
|
||||
path: ./.turbo
|
||||
|
||||
- name: Mount Docker buildkit sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-buildkit-cache
|
||||
key: ${{ github.repository }}-buildkit-cache-${{ github.ref_name }}
|
||||
path: /tmp/.buildkit-cache
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
echo "📦 Installing dependencies with pnpm..."
|
||||
pnpm install --frozen-lockfile --prefer-offline
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build with Turbo
|
||||
run: |
|
||||
echo "🔨 Building server with Turbo (using sticky disk cache)..."
|
||||
pnpm turbo run build --filter=@buster-app/server
|
||||
echo "🔨 Building server with Turbo..."
|
||||
# Build with optimized settings for Docker
|
||||
pnpm turbo run build --filter=@buster-app/server...
|
||||
echo "✅ Build complete!"
|
||||
env:
|
||||
NODE_ENV: production
|
||||
DOCKER_BUILD: true
|
||||
CI: true
|
||||
TURBO_CACHE_DIR: .turbo
|
||||
TURBO_TELEMETRY_DISABLED: 1
|
||||
|
||||
- name: Build server bundle
|
||||
run: |
|
||||
|
@ -99,7 +94,7 @@ jobs:
|
|||
|
||||
# Install production dependencies only
|
||||
cd /tmp/prod-deps
|
||||
pnpm install --frozen-lockfile --prod --ignore-scripts --no-optional
|
||||
pnpm install --frozen-lockfile --prod --no-optional
|
||||
|
||||
# Copy back to workspace
|
||||
cd -
|
||||
|
@ -108,7 +103,7 @@ jobs:
|
|||
cp -r apps/server/dist docker-context/
|
||||
cp apps/server/package.json docker-context/
|
||||
|
||||
- name: Set up Docker Builder with Blacksmith cache
|
||||
- name: Set up Docker Builder
|
||||
uses: useblacksmith/setup-docker-builder@v1
|
||||
|
||||
- name: Log in to GitHub Container Registry
|
||||
|
@ -150,6 +145,9 @@ jobs:
|
|||
build-args: |
|
||||
COMMIT_SHA=${{ steps.meta.outputs.sha_short }}
|
||||
BUILD_DATE=${{ steps.meta.outputs.timestamp }}
|
||||
platforms: linux/amd64
|
||||
cache-from: type=local,src=/tmp/.buildkit-cache
|
||||
cache-to: type=local,dest=/tmp/.buildkit-cache,mode=max
|
||||
|
||||
- name: Output image details
|
||||
run: |
|
||||
|
|
|
@ -27,23 +27,9 @@ jobs:
|
|||
with:
|
||||
node-version: 22
|
||||
cache: 'pnpm'
|
||||
|
||||
- name: Fix pnpm store permissions
|
||||
run: |
|
||||
STORE_PATH=$(pnpm store path --silent)
|
||||
if [ -d "$STORE_PATH" ]; then
|
||||
sudo chown -R $(whoami):$(whoami) "$STORE_PATH" || true
|
||||
chmod -R u+rw "$STORE_PATH" || true
|
||||
fi
|
||||
|
||||
- name: Mount Turbo cache sticky disk
|
||||
uses: useblacksmith/stickydisk@v1
|
||||
with:
|
||||
key: ${{ github.repository }}-turbo-cache
|
||||
path: ./.turbo
|
||||
|
||||
- name: Install dependencies
|
||||
run: pnpm install --frozen-lockfile --prefer-offline
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: 🚀 Deploy to ${{ github.ref_name == 'main' && 'Production' || 'Staging' }}
|
||||
env:
|
||||
|
|
Loading…
Reference in New Issue