payment #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Frontend CI/CD | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Cache dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.npm | |
key: ${{ runner.OS }}-node-${{ hashFiles('**/package-lock.json') }}-new-key | |
restore-keys: | | |
${{ runner.OS }}-node- | |
- name: Install dependencies | |
run: npm ci | |
continue-on-error: false | |
- name: Run tests | |
run: npm test -- --passWithNoTests | |
continue-on-error: false | |
- name: Build project | |
run: npm run build | |
env: | |
VITE_API_URL: ${{ secrets.VITE_API_URL }} | |
VITE_PARTNER_API_URL: ${{ secrets.VITE_PARTNER_API_URL }} | |
VITE_PUBLIC_API_URL: https://api.odcloud.kr/api/nts-businessman/v1/status | |
VITE_PUBLIC_API_KEY: ${{ secrets.VITE_PUBLIC_API_KEY }} | |
VITE_KAKAO_REST_API_KEY: ${{ secrets.VITE_KAKAO_REST_API_KEY }} | |
VITE_KAKAO_REDIRECT_URI: ${{ secrets.VITE_KAKAO_REDIRECT_URI }} | |
VITE_IMP_KEY: ${{ secrets.VITE_IMP_KEY }} | |
continue-on-error: false | |
- name: Build project | |
run: npm run build | |
env: | |
VITE_API_URL_MEMBER: ${{ secrets.API_URL_MEMBER }} | |
VITE_API_URL_PARTNER: ${{ secrets.API_URL_PARTNER }} | |
continue-on-error: false | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Deploy to S3 | |
run: | | |
aws s3 sync dist/ s3://${{ secrets.S3_BUCKET }} --delete | |
continue-on-error: false | |
- name: Invalidate CloudFront cache | |
run: | | |
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" | |
continue-on-error: false |