cheatingchelsea/.github/workflows/nextjs.yml
Derek Slenk 626219620b Add secrets configuration and deployment scripts
- Added GitHub Actions secrets configuration for deployment
- Updated next.config.ts with environment variables
- Modified package.json for production deployment
- Added robots.ts and sitemap.ts configuration
- Created deployment scripts directory
2025-06-29 17:42:11 -04:00

69 lines
2.2 KiB
YAML

# Workflow for building and deploying a Next.js site to AWS S3
name: Deploy Next.js site to S3
on:
# Runs on pushes targeting the default branch
push:
branches: ["master"]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
concurrency:
group: "s3-deployment"
cancel-in-progress: false
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: 'npm'
- name: Create .env.local file
run: |
echo "YOUTUBE_API_KEY=${{ secrets.YOUTUBE_API_KEY }}" > .env.local
echo "S3_BUCKET_NAME=${{ secrets.S3_BUCKET_NAME }}" >> .env.local
- name: Install dependencies
run: npm ci
- name: Restore Next.js cache
uses: actions/cache@v4
with:
path: |
.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
- name: Build Next.js site
env:
YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }}
S3_BUCKET_NAME: ${{ secrets.S3_BUCKET_NAME }}
run: npm run build:static
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::499518182498:role/cheatingchelsea-github-deployment
aws-region: us-east-2
- name: Deploy to S3
run: |
aws s3 sync out/ s3://${{ secrets.S3_BUCKET_NAME }} --delete --no-cli-pager
- name: Output deployment URL
run: |
echo "🎉 Deployment successful!"
echo "Your site is available at: http://${{ secrets.S3_BUCKET_NAME }}.s3-website-us-east-2.amazonaws.com"