Skip to content

Remove fetching and display of sponsored links on homepage. #84

Remove fetching and display of sponsored links on homepage.

Remove fetching and display of sponsored links on homepage. #84

name: Test, Build, and Deploy
on:
push:
branches: [ master ]
workflow_dispatch:
jobs:
# Run Cypress tests
test:
runs-on: ubuntu-latest
timeout-minutes: 20
env:
NODE_ENV: test
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 18
- name: Install dependencies
run: yarn install
- name: Build Next.js app
run: yarn build
env:
NODE_ENV: production
- name: Debug - Test WordPress API Access
run: |
echo "Testing WordPress API from GitHub Actions..."
echo "--- Response Headers ---"
curl -I -s "https://wp.dailybruin.com/wp-json/wp/v2/posts?per_page=1" || true
echo ""
echo "--- Response Body (first 500 chars) ---"
curl -s "https://wp.dailybruin.com/wp-json/wp/v2/posts?per_page=1" | head -c 500 || true
echo ""
echo "--- With User-Agent header ---"
curl -s -H "User-Agent: Mozilla/5.0 (compatible; DailyBruin/1.0)" "https://wp.dailybruin.com/wp-json/wp/v2/posts?per_page=1" | head -c 500 || true
- name: Start server and run Cypress
uses: cypress-io/github-action@v6
with:
install: false
start: yarn next start
# Use health check endpoint instead of homepage to avoid WordPress API dependency
wait-on: 'http://localhost:3000/api/healthy'
wait-on-timeout: 120000
browser: chrome
config: pageLoadTimeout=120000,defaultCommandTimeout=20000
env:
# Increase timeouts for CI environment
CYPRESS_PAGE_LOAD_TIMEOUT: 120000
CYPRESS_DEFAULT_COMMAND_TIMEOUT: 20000
# Build and deploy (only runs if tests pass)
build-and-deploy:
runs-on: ubuntu-latest
needs: test
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u "${{ secrets.DOCKERHUB_USERNAME }}" --password-stdin
- name: Build and push Docker image
run: |
docker buildx build --platform linux/amd64,linux/arm64 \
--tag dailybruin/flamingo:latest \
--push .
- name: Install doctl
run: |
curl -sL https://github.com/digitalocean/doctl/releases/download/v1.99.0/doctl-1.99.0-linux-amd64.tar.gz | tar -xzv
sudo mv doctl /usr/local/bin/
- name: Authenticate doctl
run: |
doctl auth init --access-token ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Write kubeconfig to file
run: |
echo "${{ secrets.KUBECONFIG }}" > kubeconfig.yaml
- name: Update Kubernetes deployment
env:
KUBECONFIG: kubeconfig.yaml
run: |
kubectl set image deployment/flamingo flamingo=dailybruin/flamingo:latest
kubectl rollout restart deployment flamingo
kubectl rollout status deployment/flamingo