Merge pull request #130 from IT-Cotato/hotfix/COT-6_implement_edit_cs… #208
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 Pipeline | |
on: | |
push: | |
branches: | |
- "*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Cache Node.js modules | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.npm | |
~/.yarn | |
node_modules | |
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Check Node v | |
run: node -v | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: yarn build | |
- name: Save Build Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifact | |
path: | | |
build | |
appspec.yml | |
deploy.sh | |
production-deploy: | |
needs: build | |
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/release' | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Download Build Artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-artifact | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
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: Zip Build Folder | |
run: zip -qq -r build-fe.zip build appspec.yml deploy.sh | |
shell: bash | |
- name: Upload to S3 | |
run: | | |
aws s3 cp build-fe.zip s3://${{ secrets.AWS_S3_BUCKET_NAME }}/build-fe.zip --region ap-northeast-2 | |
- name: Deploy | |
run: | | |
if [ "${GITHUB_REF}" == "refs/heads/main" ]; then | |
DEPLOYMENT_GROUP_NAME="cotato-deploy-fe-production" | |
elif [ "${GITHUB_REF}" == "refs/heads/release" ]; then | |
DEPLOYMENT_GROUP_NAME="cotato-deploy-fe-release" | |
fi | |
aws deploy create-deployment \ | |
--application-name cotato-deploy \ | |
--deployment-config-name CodeDeployDefault.AllAtOnce \ | |
--deployment-group-name ${DEPLOYMENT_GROUP_NAME} \ | |
--s3-location bucket=${{ secrets.AWS_S3_BUCKET_NAME }},key=build-fe.zip,bundleType=zip |