test: CD check after .env #487
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
# This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: deploy | |
on: | |
push: | |
branches: [develop] | |
pull_request: | |
branches: [develop] # develop 브랜치에 push/pr 했을 때 workflow를 trigger 함. | |
jobs: | |
build: | |
runs-on: ubuntu-latest # 여기서 사용할 가상 환경의 인스턴스 지정하기. | |
strategy: | |
matrix: | |
node-version: [16.16.0] #노드 버전 -> 서경 16.13.2 | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
steps: | |
- name: Checkout source code. # 레포의 코드를 CI 서버로 내려받은 후 특정 브랜치로 전환 | |
uses: actions/checkout@v2 | |
- name: Use Node.js ${{ matrix.node-version }} # 노드 설치 | |
uses: actions/setup-node@v2 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Check Npm -v | |
run: npm -v | |
- name: create env file # 깃헙에 등록한 환경변수들로 .env 생성. | |
working-directory: ./ | |
run: | | |
pwd | |
touch .env | |
echo PORT=${{ secrets.PORT }} >> .env | |
echo MONGODB_URI=${{ secrets.MONGODB_URI }} >> .env | |
echo S3_ACCESS_KEY=${{ secrets.S3_ACCESS_KEY }} >> .env | |
echo S3_SECRET_KEY=${{ secrets.S3_SECRET_KEY }} >> .env | |
echo BUCKET_NAME=${{ secrets.BUCKET_NAME }} >> .env | |
echo AWS_ACCESS_KEY_ID=${{ secrets.AWS_ACCESS_KEY_ID }} >> .env | |
echo AWS_SECRET_ACCESS_KEY=${{ secrets.AWS_SECRET_ACCESS_KEY }} >> .env | |
echo JWT_SECRET=${{ secrets.JWT_SECRET }} >> .env | |
echo JWT_ALGO=${{ secrets.JWT_ALGO }} >> .env | |
echo ACEESSTOKEN_EXPIRE=${{ secrets.ACEESSTOKEN_EXPIRE }} >> .env | |
echo REFRESHTOKEN_EXPIRE=${{ secrets.REFRESHTOKEN_EXPIRE }} >> .env | |
cat .env | |
- name: create json file # firebase-admin.json 생성. | |
working-directory: ./src/config | |
env: | |
FIREBASE_ADMIN: ${{ secrets.FCM_ACCOUNT_KEY }} | |
run: | | |
touch firebase-admin.json | |
echo $FIREBASE_ADMIN >> firebase-admin.json | |
- name: build server files # yarn으로 필요한 디펜던시 설치 후 빌드 | |
working-directory: ./ | |
run: | | |
yarn | |
yarn run build | |
- name: zip file | |
run: zip -r recordream.zip ./dist ./scripts ./build ./appspec.yml ./.env ./package.json | |
- name: AWS configure credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
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: upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./recordream.zip s3://recordream-new-build/deploy/ | |
- name: deploy with AWS codeDeploy | |
run: aws deploy create-deployment | |
--application-name recordream-codedeploy | |
--deployment-config-name CodeDeployDefault.OneAtATime | |
--deployment-group-name GROUP | |
--s3-location bucket=recordream-build,bundleType=zip,key=deploy/recordream.zip |