Skip to content

Merge pull request #283 from ODOICHON/feat/#281 #71

Merge pull request #283 from ODOICHON/feat/#281

Merge pull request #283 from ODOICHON/feat/#281 #71

Workflow file for this run

name: Deploy
on:
push:
branches: ['main', 'develop']
env:
PROJECT_NAME: duaily-client
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout source code. # Repo checkout
uses: actions/checkout@v2
- name: Check Node v # Node v ํ™•์ธ
run: node -v
- name: Cache node modules # node modules ์บ์‹ฑ
uses: actions/cache@v1
with: # with ๊ตฌ๋ฌธ์œผ๋กœ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, path์™€ key๋ฅผ ๋ฐ˜๋“œ์‹œ ์„ค์ •ํ•ด์ฃผ์–ด์•ผ ํ•จ
path: node_modules # ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ฌ ์บ์‹œ ๋Œ€์ƒ ํด๋”
key: ${{ runner.OS }}-build-${{ hashFiles('**/package-lock.json') }} # ์ €์žฅํ•˜๊ณ  ๋ถˆ๋Ÿฌ์˜ฌ ๋•Œ ์‹๋ณ„ํ•  ์ˆ˜ ์žˆ๋Š” ํ‚ค ๊ฐ’
restore-keys:
| # ์บ์‹œ key๊ฐ€ ์ผ์น˜ํ•˜๋Š” ๊ฒƒ์ด ์—†์„ ๋•Œ, ์ฐจ์„ ํƒ์œผ๋กœ ์บ์‹ฑ ํด๋”๋ฅผ ์ฐพ๋Š” key
${{ runner.OS }}-build-
${{ runner.OS }}-
- name: Install Dependencies # ์˜์กด ํŒŒ์ผ ์„ค์น˜
run: yarn install --frozen-lockfile
- name: Setting .env (Dev) # ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ธํŒ… (DEV)
if: contains(github.ref, 'develop')
run: echo "${{ secrets.REACT_ENV_DEV }}" >> .env
- name: Setting .env (Prod) # ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ธํŒ… (PROD)
if: contains(github.ref, 'main')
run: |
echo "${{ secrets.REACT_ENV }}" >> .env
- name: Build # React Build
run: yarn build
- name: Modify appspec.yml (Dev)
if: contains(github.ref, 'develop')
run: |
sed -i "s|destination: /home/filename/client|destination: /home/${{ secrets.APPSPEC_FILES_FILENAME_DEV }}/client|g" appspec.yml
sed -i "s|owner: owner|owner: ${{ secrets.APPSPEC_PERMISSIONS_OWNER_DEV }}|g" appspec.yml
sed -i "s|group: group|group: ${{ secrets.APPSPEC_PERMISSIONS_GROUP_DEV}}|g" appspec.yml
- name: Modify appspec.yml (Prod)
if: contains(github.ref, 'main')
run: |
sed -i "s|destination: /home/filename/client|destination: /home/${{ secrets.APPSPEC_FILES_FILENAME }}/client|g" appspec.yml
sed -i "s|owner: owner|owner: ${{ secrets.APPSPEC_PERMISSIONS_OWNER }}|g" appspec.yml
sed -i "s|group: group|group: ${{ secrets.APPSPEC_PERMISSIONS_GROUP}}|g" appspec.yml
- name: zip create # zip ํŒŒ์ผ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค
run: zip -r ./$GITHUB_SHA.zip ./dist appspec.yml
shell: bash
- name: Configure AWS credentials (Dev) # AWS ์„ธํŒ… (DEV)
if: contains(github.ref, 'develop')
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_DEV }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_DEV }}
aws-region: ${{ secrets.AWS_REGION_DEV }}
- name: Configure AWS credentials (Prod) # AWS ์„ธํŒ… (PROD)
if: contains(github.ref, 'main')
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 (Dev) # S3์— ํŒŒ์ผ ์—…๋กœ๋“œ (DEV)
if: contains(github.ref, 'develop')
run: aws s3 cp --region ${{ secrets.S3_REGION_DEV }} ./$GITHUB_SHA.zip s3://${{ secrets.S3_BUCKET_NAME_DEV }}/$PROJECT_NAME/$GITHUB_SHA.zip
- name: Upload to S3 (Prod) # S3์— ํŒŒ์ผ ์—…๋กœ๋“œ (PROD)
if: contains(github.ref, 'main')
run: aws s3 cp --region ${{ secrets.S3_REGION }} ./$GITHUB_SHA.zip s3://${{ secrets.S3_BUCKET_NAME }}/$PROJECT_NAME/$GITHUB_SHA.zip
- name: Code Deploy (Dev) # CodeDeploy ๋ฐฐํฌ (DEV)
if: contains(github.ref, 'develop')
run: |
aws deploy create-deployment \
--application-name duaily-dev-deploy \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ secrets.DEPLOY_GROUP_DEV }} \
--s3-location bucket=${{ secrets.S3_BUCKET_NAME_DEV }},bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip
- name: Code Deploy (Prod) # CodeDeploy ๋ฐฐํฌ (PROD)
if: contains(github.ref, 'main')
run: |
aws deploy create-deployment \
--application-name duaily-deploy \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ secrets.DEPLOY_GROUP }} \
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip