Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Deploy Frontend to S3 and CloudFront

on:
push:
branches:
- main

permissions:
contents: read
id-token: write

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build
env:
VITE_API_URL: ${{ secrets.VITE_API_URL }}
run: npm run build

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v5.1.1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ secrets.AWS_REGION }}

# --delete オプションにより、ビルド生成物にない古いファイルをS3から削除
- name: Deploy to S3
run: aws s3 sync ./dist s3://${{ secrets.S3_BUCKET_NAME }} --delete

# これを行わないと、ユーザーに古いキャッシュが表示され続ける
- name: Invalidate CloudFront Cache
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"