fix: deploy.sh 수정 - pm2 로 시작 #13
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/CD | |
on: | |
push: | |
branches: | |
- master | |
env: | |
S3_BUCKET_NAME: showoffmycats-build | |
CODE_DEPLOY_APPLICATION_NAME: ray-alpha-app | |
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: alpha-group-1 | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
node-version: [18.16.0] | |
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/ | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Setup Node ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Setup Env. | |
working-directory: ./ | |
run: | | |
pwd | |
touch .env | |
echo REACT_APP_API_KEY=${{ secrets.REACT_APP_API_KEY }} >> .env | |
cat .env | |
- name: Cache dependencies | |
id: cache | |
uses: actions/cache@v3 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
# check cache-hit | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install Dependencies | |
# working-directory: ./ | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: yarn | |
- name: Build | |
# working-directory: ./ | |
run: yarn run build | |
- name: Zip files | |
run: zip -r $GITHUB_SHA.zip ./public ./scripts ./appspec.yml ./.env ./package.json ./yarn.lock | |
- name: Configure AWS 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: ${{ secrets.AWS_REGION }} | |
- name: Upload to S3 | |
run: aws s3 cp --region ${{ secrets.AWS_REGION }} ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip | |
- name: Code Deploy | |
run: aws deploy create-deployment | |
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} | |
--deployment-config-name CodeDeployDefault.OneAtATime | |
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} | |
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$GITHUB_SHA.zip |