Merge pull request #437 from softeerbootcamp-2nd/dev #26
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: CI(Frontend) | |
on: | |
workflow_dispatch: | |
push: | |
branches: ["main"] | |
paths: | |
- "frontend/**" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./frontend | |
steps: | |
- name: VM으로 파일을 전송합니다. | |
uses: actions/checkout@v3 | |
- name: Node.js 환경을 셋팅합니다. | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: 환경변수를 설정합니다. | |
run: | | |
echo "VITE_API_URL=$VITE_API_URL" >> .env | |
echo "VITE_IMG_URL=$VITE_IMG_URL" >> .env | |
env: | |
VITE_API_URL: ${{ secrets.VITE_API_URL }} | |
VITE_IMG_URL: ${{ secrets.VITE_IMG_URL }} | |
- name: 의존성 패키지들을 설치합니다. | |
run: npm ci | |
- name: 빌드를 실행합니다. | |
run: npm run build --if-present | |
- name: 빌드 결과물을 artifact로 업로드합니다. | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-frontend | |
path: frontend/dist | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: 빌드 결과물을 다운로드합니다. | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-frontend | |
- name: S3 버킷에 업로드합니다. | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
run: | | |
aws s3 sync \ | |
. s3://www.a2cartag.com \ | |
--region ap-northeast-2 \ | |
--delete |