Merge pull request #9 from derekslenk/ampl

Amplify Release
This commit is contained in:
Derek Slenk 2025-06-27 17:47:50 -04:00 committed by GitHub
commit 10a26c2c9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 3660 additions and 2571 deletions

View file

@ -4,10 +4,42 @@ frontend:
preBuild:
commands:
- npm ci
- |
# Retrieve the secret from Amplify's secret store
echo "Attempting to retrieve YouTube API key from secrets..."
# Try to get the secret using AWS CLI
if command -v aws &> /dev/null; then
# The secret path follows the pattern: /amplify/{appId}/{branchName}/YOUTUBE_API_KEY
SECRET_VALUE=$(aws secretsmanager get-secret-value --secret-id /amplify/$AWS_APP_ID/$AWS_BRANCH/YOUTUBE_API_KEY --query SecretString --output text 2>/dev/null || echo "")
if [ ! -z "$SECRET_VALUE" ] && [ "$SECRET_VALUE" != "None" ]; then
echo "YOUTUBE_API_KEY=$SECRET_VALUE" >> .env.production
echo "Successfully retrieved secret from Secrets Manager"
else
echo "Could not retrieve secret from Secrets Manager, trying SSM..."
# Try SSM Parameter Store as fallback
SECRET_VALUE=$(aws ssm get-parameter --name /amplify/$AWS_APP_ID/$AWS_BRANCH/YOUTUBE_API_KEY --with-decryption --query Parameter.Value --output text 2>/dev/null || echo "")
if [ ! -z "$SECRET_VALUE" ] && [ "$SECRET_VALUE" != "None" ]; then
echo "YOUTUBE_API_KEY=$SECRET_VALUE" >> .env.production
echo "Successfully retrieved secret from SSM"
else
echo "Could not retrieve secret from SSM either"
fi
fi
fi
# Check if the secret was set via environment variable
if [ -z "$SECRET_VALUE" ] && [ ! -z "$YOUTUBE_API_KEY" ]; then
echo "YOUTUBE_API_KEY=$YOUTUBE_API_KEY" >> .env.production
echo "Using YOUTUBE_API_KEY from environment variable"
fi
# Show what we have
if [ -f .env.production ]; then
echo "Contents of .env.production:"
cat .env.production | sed 's/=.*/=***HIDDEN***/'
else
echo "No .env.production file created"
fi
build:
commands:
- echo "YOUTUBE_API_KEY=$YOUTUBE_API_KEY" >> .env.production
- env | grep YOUTUBE_API_KEY || echo "YOUTUBE_API_KEY not found in environment"
- npm run build
artifacts:
baseDirectory: .next
@ -16,6 +48,4 @@ frontend:
cache:
paths:
- node_modules/**/*
- .next/cache/**/*
buildPath: /
appRoot: /
- .next/cache/**/*

View file

@ -24,8 +24,13 @@ const nextConfig: NextConfig = {
},
],
},
env: {
YOUTUBE_API_KEY: process.env.YOUTUBE_API_KEY || '',
// Make environment variables available to the browser
publicRuntimeConfig: {
YOUTUBE_API_KEY: process.env.YOUTUBE_API_KEY,
},
// Server-side environment variables
serverRuntimeConfig: {
YOUTUBE_API_KEY: process.env.YOUTUBE_API_KEY,
},
};

6175
package-lock.json generated

File diff suppressed because it is too large Load diff

7
src/lib/config.ts Normal file
View file

@ -0,0 +1,7 @@
// Configuration helper for environment variables
export const config = {
youtubeApiKey: process.env.YOUTUBE_API_KEY || process.env.NEXT_PUBLIC_YOUTUBE_API_KEY || '',
};
// Helper to check if we're in a server environment
export const isServer = typeof window === 'undefined';