Skip to content

feat: 사용자 상세 정치성향 및 시청 기록 조회 API를 deprecated로 표시 #102

feat: 사용자 상세 정치성향 및 시청 기록 조회 API를 deprecated로 표시

feat: 사용자 상세 정치성향 및 시청 기록 조회 API를 deprecated로 표시 #102

name: Deploy Multi-Environment Swagger UI to GitHub Pages
on:
push:
branches: [ main, master ]
paths: [ 'dev/**/*.yml', 'dev/**/*.yaml', 'prod/**/*.yml', 'prod/**/*.yaml' ]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Find OpenAPI specification files
id: find-specs
run: |
echo "🔍 Searching for OpenAPI specification files..."
DEV_FILE=""
PROD_FILE=""
for file in "dev/openapi.yml" "dev/openapi.yaml"; do
if [ -f "$file" ]; then
DEV_FILE="$file"
echo "✅ Found dev file: $file"
break
fi
done
for file in "prod/openapi.yml" "prod/openapi.yaml"; do
if [ -f "$file" ]; then
PROD_FILE="$file"
echo "✅ Found prod file: $file"
break
fi
done
echo "dev_file=$DEV_FILE" >> $GITHUB_OUTPUT
echo "prod_file=$PROD_FILE" >> $GITHUB_OUTPUT
if [ -z "$DEV_FILE" ] && [ -z "$PROD_FILE" ]; then
echo "❌ No OpenAPI specification files found!"
exit 1
fi
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Create directory structure
run: |
mkdir -p swagger-ui/dev
mkdir -p swagger-ui/prod
- name: Generate Development Environment
if: steps.find-specs.outputs.dev_file != ''
run: |
DEV_FILE="${{ steps.find-specs.outputs.dev_file }}"
SPEC_FILENAME=$(basename "$DEV_FILE")
# Copy template and replace placeholder
cp .github/templates/swagger-dev.html swagger-ui/dev/index.html
sed -i "s/SPEC_FILE_PLACEHOLDER/$SPEC_FILENAME/g" swagger-ui/dev/index.html
# Copy spec file
cp "$DEV_FILE" "swagger-ui/dev/$SPEC_FILENAME"
# Copy components file if it exists
if [ -f "dev/components.yml" ]; then
cp "dev/components.yml" "swagger-ui/dev/components.yml"
echo "✅ Components file copied"
fi
echo "✅ Development environment generated"
- name: Generate Production Environment
if: steps.find-specs.outputs.prod_file != ''
run: |
PROD_FILE="${{ steps.find-specs.outputs.prod_file }}"
SPEC_FILENAME=$(basename "$PROD_FILE")
# Copy template and replace placeholder
cp .github/templates/swagger-prod.html swagger-ui/prod/index.html
sed -i "s/SPEC_FILE_PLACEHOLDER/$SPEC_FILENAME/g" swagger-ui/prod/index.html
# Copy spec file
cp "$PROD_FILE" "swagger-ui/prod/$SPEC_FILENAME"
# Copy components file if it exists
if [ -f "prod/components.yml" ]; then
cp "prod/components.yml" "swagger-ui/prod/components.yml"
echo "✅ Components file copied"
fi
echo "✅ Production environment generated"
- name: Generate Main Index Page
run: |
DEV_FILE="${{ steps.find-specs.outputs.dev_file }}"
PROD_FILE="${{ steps.find-specs.outputs.prod_file }}"
# Copy main template
cp .github/templates/index.html swagger-ui/index.html
# Choose appropriate card templates
if [ -n "$DEV_FILE" ]; then
DEV_CARD_TEMPLATE=".github/templates/dev-card-available.html"
else
DEV_CARD_TEMPLATE=".github/templates/dev-card-unavailable.html"
fi
if [ -n "$PROD_FILE" ]; then
PROD_CARD_TEMPLATE=".github/templates/prod-card-available.html"
else
PROD_CARD_TEMPLATE=".github/templates/prod-card-unavailable.html"
fi
# Replace placeholders with card content
sed -i "/DEV_CARD_PLACEHOLDER/r $DEV_CARD_TEMPLATE" swagger-ui/index.html
sed -i "/DEV_CARD_PLACEHOLDER/d" swagger-ui/index.html
sed -i "/PROD_CARD_PLACEHOLDER/r $PROD_CARD_TEMPLATE" swagger-ui/index.html
sed -i "/PROD_CARD_PLACEHOLDER/d" swagger-ui/index.html
echo "✅ Main index page generated"
- name: Verify generated files
run: |
echo "📁 Generated files:"
find swagger-ui -type f | sort
echo ""
echo "📄 File sizes:"
find swagger-ui -type f -exec ls -lh {} \;
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: './swagger-ui'
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4