Create deploy.sh #19
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: Check Node v | |
run: node -v | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: yarn build | |
production-deploy: | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
environment: production | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Check Node v | |
run: node -v | |
- name: Install Dependencies | |
run: yarn install --frozen-lockfile | |
- name: Build | |
run: yarn build | |
- name: Generate Environment Variables File for Production | |
run: | | |
echo "REACT_APP_BASE_URL=$REACT_APP_BASE_URL" >> .env.production | |
echo "REACT_APP_API_URL=$REACT_APP_API_URL" >> .env.production | |
env: | |
REACT_APP_BASE_URL: ${{ secrets.REACT_APP_BASE_URL }} | |
REACT_APP_API_URL: ${{ secrets.REACT_APP_API_URL }} | |
- 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: aws deploy create-deployment | |
--application-name cotato-deploy | |
--deployment-config-name CodeDeployDefault.AllAtOnce | |
--deployment-group-name cotato-deploy-group | |
--s3-location bucket=${{ secrets.AWS_S3_BUCKET_NAME }},key=build-fe.zip,bundleType=zip |