빌드 파일 저장 버킷 변경 #4
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: Server Production Server CI&CD Work Flow | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
prod_CICD: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.13.2] # 개발환경과 동일하게 맞춤 | |
steps: | |
# 브랜치에 checkout해 코드를 가져온다 | |
- name: Checkout source code. | |
uses: actions/checkout@v2 | |
# node 설치 및 버전 확인한다. | |
- name: Node.js ${{ matrix.node-version }} install | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Check Npm -v | |
run: npm -v | |
# npm ci를 통해 npm install 진행 | |
- name: Npm CI | |
run: npm ci | |
#lint 통과 확인 | |
- name: Check ESLint | |
run: npm run lint | |
# .env 파일 생성 | |
- name: Create .env file | |
run: | | |
touch .env | |
echo PORT=${{ secrets.PORT }} >> .env | |
echo DB_HOST=${{ secrets.DB_HOST }} >> .env | |
echo DB_USER=${{ secrets.DB_USER }} >> .env | |
echo DB_PASSWORD=${{ secrets.DB_PASSWORD }} >> .env | |
echo DB_NAME=${{ secrets.DB_NAME }} >> .env | |
echo DB_PORT=${{ secrets.DB_PORT }} >> .env | |
echo FIREBASE_TYPE=${{ secrets.FIREBASE_TYPE }} >> .env | |
echo FIREBASE_PROJECT_ID=${{ secrets.FIREBASE_PROJECT_ID }} >> .env | |
echo FIREBASE_PRIVATE_KEY_ID=${{ secrets.FIREBASE_PRIVATE_KEY_ID }} >> .env | |
echo FIREBASE_PRIVATE_KEY=${{ secrets.FIREBASE_PRIVATE_KEY }} >> .env | |
echo FIREBASE_CLIENT_EMAIL=${{ secrets.FIREBASE_CLIENT_EMAIL }} >> .env | |
echo FIREBASE_CLIENT_ID=${{ secrets.FIREBASE_CLIENT_ID }} >> .env | |
echo FIREBASE_AUTH_URI=${{ secrets.FIREBASE_AUTH_URI }} >> .env | |
echo FIREBASE_TOKEN_URI=${{ secrets.FIREBASE_TOKEN_URI }} >> .env | |
echo FIREBASE_AUTH_PROVIDER_X509_CERT_URI=${{ secrets.FIREBASE_AUTH_PROVIDER_X509_CERT_URI }} >> .env | |
echo FIREBASE_CLIENT_X509_CERT_URI=${{ secrets.FIREBASE_CLIENT_X509_CERT_URI }} >> .env | |
echo SLACK_API_TOKEN=${{ secrets.SLACK_API_TOKEN }} >> .env | |
# 빌드하여 S3에 업로드 | |
- name: Run build (main) | |
run: | | |
npm run build:production --if-present | |
- name: Copy ecosystem.config.js | |
run: | | |
cp ./ecosystem.config.js ./dist | |
# S3에 빌드 파일 저장 | |
- name: Build file upload to S3 and PM2 script | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
run: | | |
aws s3 cp \ | |
--recursive \ | |
--region ap-northeast-2 \ | |
dist s3://wishboard-prod2-build |